What does <--filter-granularity>=file do, exactly?...
# general
c
What does --filter-granularity=file do, exactly? I noticed that when I pass this in, I still get targets in the form of
path/to/file.py:target_name
. What I’m looking for is a way to filter out all of the targets returned such that I only get things like
path/to/file.py
.
h
path/to/file.py:target_name
is the "proper name" of a file-level target (generated by
path/to:target_name
)
Are you looking for file names to pipe into a non-pants cli app?
c
Yup, exactly. I want to manually pass to pytest because currently pytest-xdist isn't supported via pants
h
Gotcha. So you can do something like:
./pants  --filter-target-type=python_test peek ::
and pluck out the sources with
jq
or some json-parsing script
Note that in Pants 2.13 you can pass the
--filter
arguments to any goal
peek
in this case
if you're on an earlier version you can pipe
./pants filter
to
./pants peek
But this is a bit elaborate
Is Pants's build-in test parallelization not sufficient for your case?
c
Is Pants’s build-in test parallelization not sufficient for your case?
It’s not, at the moment. I initially was looking to try to implement https://github.com/pantsbuild/pants/issues/15026, but encountered some issues with pytest-xdist, and wanted to try implementing a workaround in case it ended up being difficult to implement the pytest-xdist feature into Pants. (Issue I ran into is described in the thread on https://pantsbuild.slack.com/archives/C046T6T9U/p1658777475033269.)
I’m not sure if I’m encountering a bug with
--filter-target-type=python_test
. First, I tried running the following.
Copy code
./pants --changed-since=origin/master dependees --transitive --closed
This output a huge list of changed targets and corresponding dependees (with many test and non-test targets). Then, I ran the following.
Copy code
./pants --changed-since=origin/master dependees --transitive --closed --filter-target-type=python_test
This output a pruned list of the above, but seems to have overpruned. There existed tests in the first list, that did not exist in the second list. Do you know what might be happening?