Skip to content

apply_func.py: from torchtext.legacy.data import Batch #6210

@dbonner

Description

@dbonner

🐛 Bug

In the latest torchtext (version 0.9.0a0+036df73) built from source:
The name Batch is no longer located under torchtext.data
Batch is now located under torchtext.legacy.data

--Error message--
File "/home/daniel/py38/lib/python3.8/site-packages/pytorch_lightning/utilities/apply_func.py", line 28, in
from torchtext.data import Batch
ImportError: cannot import name 'Batch' from 'torchtext.data' (/home/daniel/py38/lib/python3.8/site-packages/torchtext/data/init.py)

You can fix this by changing line line 28 of pytorch_lightning/utilities/apply_func.py to:
from torchtext.legacy.data import Batch

This does not reproduce with BoringModel because BoringModel does not import torchtext.data.Batch

Expected behavior

No error message.

Environment

  • CUDA:
    - GPU:
    - A100-SXM4-40GB
    - A100-SXM4-40GB
    - A100-SXM4-40GB
    - A100-SXM4-40GB
    - A100-SXM4-40GB
    - A100-SXM4-40GB
    - A100-SXM4-40GB
    - A100-SXM4-40GB
    - available: True
    - version: 11.2
  • Packages:
    - numpy: 1.19.5
    - pyTorch_debug: False
    - pyTorch_version: 1.9.0a0+92a4ee1
    - pytorch-lightning: 1.1.5
    - torchtext: 0.9.0a0+036df73 <--------------------------
    - tqdm: 4.57.0
  • System:
    - OS: Linux
    - architecture:
    - 64bit
    - ELF
    - processor: x86_64
    - python: 3.8.8
    - version: self-balancing architecture #50-Ubuntu SMP Tue Feb 9 06:29:41 UTC 2021

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedOpen to be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions