Skip to content

Commit

Permalink
Avoid required torchtext import
Browse files Browse the repository at this point in the history
  • Loading branch information
carmocca committed Nov 30, 2021
1 parent c13b159 commit 6b814fa
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/helpers/imports.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
from pytorch_lightning.utilities.imports import _TORCH_GREATER_EQUAL_1_8
from pytorch_lightning.utilities.imports import _TORCH_GREATER_EQUAL_1_8, _TORCHTEXT_AVAILABLE

if _TORCH_GREATER_EQUAL_1_8:
from torchtext.legacy.data import Batch, Dataset, Example, Field, Iterator, LabelField
if _TORCHTEXT_AVAILABLE:
if _TORCH_GREATER_EQUAL_1_8:
from torchtext.legacy.data import Batch, Dataset, Example, Field, Iterator, LabelField
else:
from torchtext.data import Batch, Dataset, Example, Field, Iterator, LabelField
else:
from torchtext.data import Batch, Dataset, Example, Field, Iterator, LabelField # noqa: F401
Batch = type(None)
Dataset = type(None)
Example = type(None)
Field = type(None)
Iterator = type(None)
LabelField = type(None)

0 comments on commit 6b814fa

Please sign in to comment.