Is there a way of doing the below that actually wo...
# general
h
Is there a way of doing the below that actually work? I want to get all
python_distribution
targets that depend on a specific requirement, but this filter is working differently to how I expect it to.
Copy code
pants dependees --transitive --filter-target-type=python_distribution //:reqs#numpy
h
What is it doing contrary to what you expect?
a
I'm pretty sure this also didn't work for us, the target type filtering doesn't work on dependency queries.
We just wrote to an intermediary file (btw, it's annoying pants can't read spec files from stdin)...
Copy code
"$PANTS" dependents  --dependents-transitive=true "$@" > "$FULL_TARGETS"

for project in $("$PANTS" --spec-files="$FULL_TARGETS" --filter-target-type=catapult_release peek | jq -r '.[].project' | sort -u); do
So, I guess, it's dependents and dependees.
It might also only apply to 3rd party deps, that's exactly what our script is doing as well.
h
Oh, right
--filter
filters the input targets IIRC
a
(this is part of a script that tells us what apps we need to deploy to resolve vulnerabilities in a 3rd party dependency)
Hm, I wonder if that actually has any usecases, I'd find it more useful it if it filtered the output
Especially since there are warnings about "oh, you don't need filter now, you can use --filter-x"
But, obviously, they're not equivalent.
h
Yeah, I would expect filter to also work on output types but probably a separate flag would be wise. It would be useful for filter to work on every applicable command then you could create more complex dep graph queries by piping commands.
👍 1
a
Though, the filter on output is a different issue than piping comands.
Both would help, I think the piping/reading from non files for spec files one would help us more, but can't really speak for other people.
h
Well, piping commands together works as expected but having more filter functionality would enhance it.
a
Hm, how are you piping stuff? Granted, this might've been fixed in 2.18 or above, we're stuck there for now
h
Just bash piping + xargs, obviously only works for target in target out commands
a
Ah, yeah, I mean getting a list of targets from one command and then passing it to the next one, through a pipe.
We do this in a script:
Copy code
"$PANTS" dependents  --dependents-transitive=true "$@" > "$FULL_TARGETS"

"$PANTS" --spec-files="$FULL_TARGETS" --filter-target-type=catapult_release peek
Where
$FULL_TARGETS
is a temp file. So we have this above:
Copy code
FULL_TARGETS=$(mktemp)
trap "rm -f $FULL_TARGETS" EXIT
That's just annoying
f
> We do this in a script: Is this not what you're looking for?
Copy code
"$PANTS" dependents --dependents-transitive=true "$@" | xargs "$PANTS" --filter-target-type=catapult_release peek
👆 1