is it possible to ask Pants to exclude a portion o...
# general
f
is it possible to ask Pants to exclude a portion of the dependency graph at the runtime when asking for dependencies? ๐Ÿงต
In the example-python, if I modify
helloworld/translator/translator.py
and run:
Copy code
โฏ ./pants --changed-since=HEAD --changed-dependees=direct list
helloworld/greet/greeting.py:lib
helloworld/translator/translator.py:lib
helloworld/translator/translator_test.py:tests
The
greeting.py
is reported as changed because it depends on `translator.py`:
Copy code
โฏ ./pants paths --from=helloworld/greet/greeting.py --to=helloworld/translator/translator.py   
[
  [
    "helloworld/greet/greeting.py:lib",
    "helloworld/translator/translator.py:lib"
  ]
]
Is it possible when asking for changed targets to tell Pants to ignore certain areas of the dependency graph, e.g. "pretend" that the only source location is
helloworld/greet
? With this limit set, there would be no changes reported as
helloworld/translator
is not taken into account. The
list --filter-address-regex=...
filters the output only, not the "discoverable" targets. The
--source-root-patterns=[]
doesn't seem to work either, I am not sure if that's even valid to set roots at runtime? ๐Ÿ˜•
it looks plausible to do a few
./pants dependees
calls to determine who depends on what and then do filtering in multiple
./pants
calls, but was hoping to get a more concise solution?
h
Is it possible when asking for changed targets to tell Pants to ignore certain areas of the dependency graph, e.g. "pretend" that the only source location is helloworld/greet?
No. Are you going after this? https://github.com/pantsbuild/pants/issues/14243
f
thanks, Eric! No, I am not, reading the issue now! ๐Ÿ˜„
yes, you got it right in the issue, Eric. It's not the filtering of the output targets that I am interested in, but rather filtering what locations Pants should explore when searching for dependencies. Some kind of patching of what are dependencies of some target are at runtime.
With
->
indicating "importing from", e.g.
file2.py
imports from
file1.py
Copy code
dir1/
  file2.py -> file1.py
  file1.py (with changes made) -> main.py
  main.py -> dir2/lib.py
dir2/
  lib.py (with changes made)
Running
./pants --changed-since=HEAD --changed-dependees=direct list --option-setting-roots-locations="dir1/"
should report
file1.py
and
file2.py
only
Perhaps we could rephrase the question to be: "Can Pants tell me the changed files considering dependencies only within a single target?" i.e.
dir1/BUILD/python_sources()
only target