X-post from <#CGZFJRY85|pantsd> -&gt; Hi all, I am...
# development
w
X-post from #pantsd -> Hi all, I am a dev at Foursquare and currently wrapping up a tooling project that serves dependency hygiene reports to our engineers whenever a PR is opened or updated for our mono repo. The basic idea is that we have a master report that is a json blob of all of our targets with a list of all dependencies and dependees for each target, and that report is updated for effected targets on a merge. The report is a generated diff from the PR's effected targets' dependencies/dependees and the master report. My question for this channel is
whether or not there is a way to opt out .pants.d/reports/ files being written when executing a given pants command
. For large PRs I am running the
dependee
commands in parallel, and sometimes it hits a
Exception message: Path for link would overwrite an existing directory: .pants.d/reports/latest
. I've looked through pants goals and didn't see anything to toggle off the reporting, so figured I would look for some guidance here :
g
whether or not there is a way to opt out .pants.d/reports/ files being written when executing a given pants command
What version of pants are ya’ll be on?
w
it might also be the case that a good answer for this is: consider writing a Task or @rule (depending on the version) that does precisely what you want to do, by starting from a copy-paste of the dependees task
because if you want to write out info for all of the targets, you can do that in just one pass
g
For context, v2 stats (json report of workunit graph) can be opted in to and won’t write to
.pants.d/reports
if not selected (though there was a window where it did before there was a flag for it IIRC)
w
We are on
1.7.0
✔️ 1
g
I see, my comment re: json reporting wouldn’t apply then
w
We never actually write out info for all the targets except for when the first master base report was made. Since then, we just pass the list of effected targets. I haven't written a pants Task before, but let me look into it
w
https://github.com/pantsbuild/pants/blob/master/src/python/pants/backend/graph_info/tasks/dependees.py is a bit intimidating, but if you prune down to just the bit relevant to what you're doing, i think it could be pretty small
but... it also looks like it supports json output, which seems potentially relevant...
g
Hrm… yeah fwict that doesn’t put anything into the reports dir mentioned above.
w
ah, sorry: i just meant that if the goal is to "find the dependees of a bunch of targets", you might be able to run that once for the affected targets, and then consume the json output to figure out which depended on which
w
Ya, was just looking through that file. I familiarized myself with it earlier when I started this project, but still not entirely sure at what stage in the pants call process that those reports are being generated, since it doesn't seem to be at the task level
Ya, that is actually a better idea anyways!
Still interested in understanding these reports being written though since I've started on this hunt, but I think customizing the dependee task for this is the right move for my situation
w
to be clear, the json output i'm talking about at this point is the
dependees --output-format=json
flag
if that does what it looks like it might do, you might not need to modify the task at all
w
Actually I remember now
The issue is that it returns all the dependees for all the targets you pass without differentiation
Where as the report needs to know what dependees belong to each target passed
w
gotcha. i thought i was seeing that the json ended up giving enough information to create a graph
w
At least I am pretty sure. I started this while ago, will run again but I remember there being a reason I had to run the individually and I think that is it