hey :smile: I'm having some issues with transitive...
# general
b
hey ๐Ÿ˜„ I'm having some issues with transitive dependencies. my torch dependencies from
transformers
is not resolved by
pants
(since
transformers
resolves it at runtime). I can solve that with my
pex_binary
for production by using
inherit_path="fallback"
. How can I achieve the same solution for my dev script that is executed with
python_source
? here is my
BUILD
file:
Copy code
python_source(
    name="dev",
    dependencies=[":api"],
    source="src/serve.py",
    restartable=True,
)

pex_binary(
    name="prod",
    dependencies=[":api"],
    entry_point="src/serve.py",
    inherit_path="fallback",
)

python_sources(
    name="api",
    sources=["**/*.py"],
)

python_tests(
    name="tests",
    sources=["tests/**/test_*.py"],
)

python_test_utils(
    name="test_utils",
    sources=["tests/conftest.py"],
)
even having torch installed on my virtualenv, Pants for some reason still can't use it
h
Pants creates its own virtualenvs, so I'm not sure which virtualenv you're referring to?
If you want torch to be present you have to depend on it explicitly
One way to do that was mentioned in the thread a few days ago on this topic
b
@happy-kitchen-89482 I would like to avoid having to have torch within my Pants virtualenv mainly because that increases the deployment time of the app drastically
I mean, while building the production env I would prefer inheriting from PATH (like I'm doing now)
that does work for my prod pex_binary, but it doesnt for the dev python source, and I cant use pex_binaries since they cant be restartable
h
I see, I think. So you want to be able to
pants run
some source file on some existing venv, instead of one that Pants creates?
b
this can be an option, for sure ๐Ÿ˜„
the main issue is being able to fallback to PATH if a given dependency doesnt exist (which is supported on
pex_binary
)
otherwise having torch inside Pants will slow down us a lot, since installing torch is extremely slow, and pants reinstall the dependencies from time to time
h
Hmm, I think @flat-zoo-31952 has some perspective on this, although I'm not sure this can be done today, but it's a good use case to know about for https://github.com/pantsbuild/pants/discussions/20897
๐Ÿ™ 1
I believe it's even mentioned there
f
I have to admit I havenโ€™t really followed the progress on provided dependencies
b
@happy-kitchen-89482 cool ๐Ÿ˜„ I'll follow that discussion if we can have something like that it would be amazing. For some specific workflows (usually when using ML tools) this would be desirable since torch (and most ML frameworks) are extremely slow to install. We don't need exactly the feature I asked for (being capable of falling back to locally installed modules), what we would need to ensure is avoiding reinstalling it
at least, if I understood correctly, from time to time pants reinstalls the dependencies when we run a given source