hundreds-raincoat-83920
12/15/2021, 11:41 PMpex_binary(
name="train",
entry_point="train.py",
dependencies=[
"src/data:data",
"!!src/data:torch",
"examples/ml_example:torch"
]
)
and I still get `The target examples/ml_example/train.py imports torch.nn.functional
, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['examples/ml_example:torch', 'src/data:torch']` . If I get rid of "!!src/data:torch"
pants says:
More than one direct requirement is satisfied by torch 1.10.1:
0. torch
1. torch>=1.10
My goal is to allow varying level of strictness - data should support a wide variety of torches, while other people can do what they want. Is there a better way than doing "!!src/data:torch"
?hundreds-raincoat-83920
12/15/2021, 11:44 PMhundreds-father-404
12/15/2021, 11:49 PMexamples/ml_example/train.py
. You are disambiguating what version of torch
to use with the pex_binary
that depends on examples/ml_example/train.py
, but train.py
still is using Torch and Pants wants to infer a dep and doesn't know what to do
Instead, you could do this in examples/ml_example/BUILD
python_sources(
overrides={
"train.py": {"dependencies": ["examples/ml_example:torch"]},
},
)
Then, train.py
will be fixed to use the correct thing and Pants will ignore src/data:data
for it because the dep is already satisfied by "examples/ml_example:torch"
. That warning is fixed.hundreds-raincoat-83920
12/15/2021, 11:51 PMhundreds-father-404
12/15/2021, 11:53 PM"!!src/data:torch"
and "examples/ml_example:torch"
from the pex_binary
but I'm honestly not certain. You can use ./pants dependencies --transitive path/to:pex_binary
while debugging
I think that it should be safe to remove "examples/ml_example:torch"
if you make the above change to examples/ml_example/train.py
because it will already be depending on "examples/ml_example:torch"
itself
But I'm unclear if you will still need to keep "!!src/data:torch"
. That depends on if any of the deps of the pex_binary
are transitively depending on it. If so, you'll need to use the !!
to make sure that no matter what it doesn't get pulled inhundreds-father-404
12/15/2021, 11:53 PMhundreds-raincoat-83920
12/16/2021, 12:22 AMpython_requirements()
python_sources(
overrides={
"train.py": {"dependencies": ["examples/ml_example:torch"]},
},
)
pex_binary(name="train", entry_point="train.py", dependencies=["!!src/data:torch"])
if I don’t have the !!
I get the double torch pip complaint, if I get rid of the overrides I get the warninghundreds-raincoat-83920
12/16/2021, 1:13 AM./pants lint ::
, but I can’t seem to track it down when running lint on smaller parts of the repo. Is there a flag I can pass to lint to see what it’s trying to lint?hundreds-father-404
12/16/2021, 1:19 AMlint
tries to batch everything in a single run, hm..is this Pylint that's giving you issues?
What you really want right now is "multiple resolves", where Pants has first-class support for part of your repo using lockfile A and another using lockfile B. When we have that, Pants will automatically partition your repo with ./pants lint ::
into a run for resolve A, another for resolve B, etc
We laid a ton of groundwork for that 2-3 months ago with Pants 2.7, and it's now my main priority. We're starting with getting things working how we like for Java and Scala because they're experimental, and then going to bring to Python
--
In the meantime, the best workarounds are to either:
1) use --lint-per-file-caching
, which will run a separate process per file. Warning that this will probably be much slower, or
2) Use skip_pylint
on targets that are giving you issues.
--
I can’t seem to track it downTry
./pants dependees src/data:data
🙂 one of my fav features of Pantshundreds-father-404
12/16/2021, 1:20 AMtorch
, we want to make it much more ergonomic for consumers to say which version to use. No need for them to deal with that "ambiguous dependency inference" warning