breezy-pizza-55668
07/16/2024, 7:16 PMFile "/home/delucca/.cache/pants/named_caches/pex_root/venvs/s/17fb5414/venv/lib/python3.11/site-packages/transformers/utils/import_utils.py", line 1495, in requires_backends
raise ImportError("".join(failed))
โ ['\nAutoModelForTokenClassification requires the PyTorch library but it was not found in your environment. Checkout the instr...
ImportError:
AutoModelForTokenClassification requires the PyTorch library but it was not found in your environment. Checkout the instructions on the
installation page: <https://pytorch.org/get-started/locally/> and follow the ones that match your environment.
Please note that you may need to restart your runtime after installation.
(I've already generated lockfiles after I've added it to my pyproject.toml
This is my `pyproject.toml`:
[project]
name = "item-matcher"
version = "0.1.0"
dependencies = [
"fastapi>=0.11.0",
"uvicorn>=0.30.1",
"loguru>=0.7.2",
"google-cloud-storage>=2.17.0",
"google-auth>=2.31.0",
"google-cloud-secret-manager>=2.20.1",
"msgpack>=1.0.8",
"dependency-injector>=4.41.0",
"typing-extensions>=4.12.2",
"transformers>=4.42.4",
"numpy>=1.26.4",
"torch>=2.0.0",
"torchvision>=0.15.0",
"torchaudio>=2.0.0"
]
[tool.pants]
pants_version = "2.21.0"
[tool.pants.backend.python]
interpreter_constraints = ["==3.11.*"]
[project.optional-dependencies]
dev = [
"pytest>=8.2.2",
"pytest-docker>=3.1.1",
"httpx>=0.27.0",
]
breezy-pizza-55668
07/16/2024, 7:21 PMbreezy-pizza-55668
07/16/2024, 7:22 PMimportlib.util.find_spec
returns None
even if I try to pick pytest
(that 100% sure is installed on my env since I use it)breezy-pizza-55668
07/16/2024, 7:22 PMtransformers
lib uses it to decide if torch
is installedbreezy-pizza-55668
07/16/2024, 7:22 PMimportlib.util.find_spec
doesn't work when running dependencies from pants
?breezy-pizza-55668
07/16/2024, 7:34 PMimport torch
anywhere in the code it fixes the issue. So, pants doesn't resolve the dependencies a given dependency is using? ๐คbreezy-pizza-55668
07/16/2024, 7:37 PMtransformers
lib code, it seems they always import torch
on runtime, during a function executionbreezy-pizza-55668
07/16/2024, 7:37 PMimport torch
manually on my side?steep-eve-20716
07/16/2024, 8:28 PMpoetry_requirements(
name="poetry",
# pip is unable to infer these transitive dependencies
overrides={
"transformers": {"dependencies": [":poetry#torch"]},
},
)
breezy-pizza-55668
07/17/2024, 3:14 AMhappy-kitchen-89482
07/17/2024, 10:01 AMimport
it usually means that Pants dep inference had no way to infer a dep (without that explicit import
) so you need to add it manuallysteep-eve-20716
07/17/2024, 4:29 PMhappy-kitchen-89482
07/17/2024, 4:35 PMtransformers
works with or without torch
(albeit with different behavior in each case), it does not require it?happy-kitchen-89482
07/17/2024, 4:36 PMRequires-Dist
wheel metadata?some-restaurant-1855
07/17/2024, 6:23 PM<https://github.com/huggingface/transformers/blob/main/setup.py>
bc yeah, transformers works without torchsome-restaurant-1855
07/17/2024, 6:24 PMhappy-kitchen-89482
07/17/2024, 6:32 PMhappy-kitchen-89482
07/17/2024, 6:32 PMhappy-kitchen-89482
07/17/2024, 6:32 PMhappy-kitchen-89482
07/17/2024, 6:33 PMhappy-kitchen-89482
07/17/2024, 6:33 PMhappy-kitchen-89482
07/17/2024, 6:33 PMsome-restaurant-1855
07/17/2024, 6:33 PMsteep-eve-20716
07/17/2024, 6:33 PMhappy-kitchen-89482
07/17/2024, 6:34 PMsome-restaurant-1855
07/17/2024, 6:34 PMhappy-kitchen-89482
07/17/2024, 6:34 PMsome-restaurant-1855
07/17/2024, 6:40 PMsteep-eve-20716
07/17/2024, 6:41 PMtransformers
and the transformers[torch]
extra, automatically infer the relationship between the two instead of manually declaring it?breezy-pizza-55668
07/17/2024, 7:18 PMbreezy-pizza-55668
07/17/2024, 7:18 PMsome-restaurant-1855
07/17/2024, 7:31 PMsome-restaurant-1855
07/17/2024, 7:31 PMhappy-kitchen-89482
07/17/2024, 8:07 PMhappy-kitchen-89482
07/17/2024, 8:08 PM