You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When transformers.models.auto is imported somewhere before torchmetrics, the following error is raised: ValueError: transformers.models.auto.__spec__ is None.
This causes find_spec to raise an uncatched ValueError, introduced in #739 with _TRANSFORMERS_AUTO_AVAILABLE = _module_available("transformers.models.auto")
To Reproduce
Steps to reproduce the behavior:
pip install transformers
pip install torchmetrics
python -c "from transformers.models import auto; from torchmetrics import Metric"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "envs/test-spec/lib/python3.7/site-packages/torchmetrics/__init__.py", line 14, in <module>
from torchmetrics import functional # noqa: E402
File "envs/test-spec/lib/python3.7/site-packages/torchmetrics/functional/__init__.py", line 14, in <module>
from torchmetrics.functional.audio.pit import permutation_invariant_training, pit, pit_permutate
File "envs/test-spec/lib/python3.7/site-packages/torchmetrics/functional/audio/__init__.py", line 14, in <module>
from torchmetrics.functional.audio.pit import permutation_invariant_training, pit, pit_permutate # noqa: F401
File "envs/test-spec/lib/python3.7/site-packages/torchmetrics/functional/audio/pit.py", line 24, in <module>
from torchmetrics.utilities.imports import _SCIPY_AVAILABLE
File "envs/test-spec/lib/python3.7/site-packages/torchmetrics/utilities/imports.py", line 92, in <module>
_TRANSFORMERS_AUTO_AVAILABLE = _module_available("transformers.models.auto")
File "envs/test-spec/lib/python3.7/site-packages/torchmetrics/utilities/imports.py", line 36, in _module_available
return find_spec(module_path) is not None
File "envs/test-spec/lib/python3.7/importlib/util.py", line 117, in find_spec
raise ValueError('{}.__spec__ is None'.format(name))
ValueError: transformers.models.auto.__spec__ is None
Expected behavior
No exception being raised.
Environment
PyTorch Version (e.g., 1.0): 1.10.1'
OS (e.g., Linux): MacOS
How you installed PyTorch (conda, pip, source): pip
Python version: 3.7, 3.8, 3.9, 3.10
The text was updated successfully, but these errors were encountered:
that is interesting, I can replicate it and it is about this combination in a single python call, in contrast, if I call them separately everything works fine:
🐛 Bug
When
transformers.models.auto
is imported somewhere beforetorchmetrics
, the following error is raised:ValueError: transformers.models.auto.__spec__ is None
.I believe this is caused by how transformers lazyly adds this module to
sys.modules
combined to how torchmetrics checks for it's availability with _module_available.This causes find_spec to raise an uncatched ValueError, introduced in #739 with
_TRANSFORMERS_AUTO_AVAILABLE = _module_available("transformers.models.auto")
To Reproduce
Steps to reproduce the behavior:
pip install transformers
pip install torchmetrics
python -c "from transformers.models import auto; from torchmetrics import Metric"
Expected behavior
No exception being raised.
Environment
conda
,pip
, source): pipThe text was updated successfully, but these errors were encountered: