Curious if anyone can suggest a tool for visualiza...
# general
r
Curious if anyone can suggest a tool for visualization of a Python project dependency graph? Looking to have a deeper understanding on how
./pants dependees --transitive <file_path>
finds links to files. The current dump shows all dependees for a file but not how they are connected.
b
I made an -ad-hoc script using
d3-force-graph
and the output of
./pants peek
@happy-kitchen-89482 also maybe had a way, I can't remember
w
can also use
./pants paths --from=$target1 --to=$target2
βž• 1
r
to note this repo using version 2.7.0, so not sure if we have these features or not. We are planning to upgrade. We did write custom script to build some visual of what pants dependees outputs but want to see if we don't need to reinvent the wheel here. I heard of codesee.io not sure if that offers a good view of what pants finds.
I think what @witty-crayon-22786 mentioned is the syntax we would need. How does the output work for that goal?
w
it’s a JSON list of the various paths between two targets
so it effectively explains all of the reasons that target1 depends on target2
r
that's awesome. I'm going to experiment a bit and see how it works. It may be a bit fine grained as I was hoping to have a way to visualize this for every path in the repo.
b
@rapid-bird-79300 use
./pants peek ::
for that πŸ™‚
w
yea, @happy-kitchen-89482 has something for that. and you can convert the
peek
output to
dot
. it is generally very interesting, but
peek
can be better for debugging particular issues
b
peek
gives you JSON metadata for the CLI arg. In this case using
::
means "everything". So: "give me all the metadata for the entire repo". Then filter using
jq
or your favorite json lib
r
does pants peek show us the paths to dependees? I thought that operated similar to
dependees
which currently does not show the paths.
b
no, but you can build that using the information, since you have every edge
r
yeah that's what we are experimenting with in our custom script but wanted to see if we didn't have to re-invent the wheel here.
I like the d3 force graph visuals. It seems easy enough to setup, will give that a go. We are building the graph using anytree with dotexplorer and render tree txt output, but the project is quite large so it has been a pain. Also I noticed
./pants dependees --no-transitive --output-format=json --output-file=app_dependees.txt app/::
is not sufficient because it does not show files. Where
/pants dependees --no-transitive --output-format=json --output-file=app_dependees.txt 'app/**/*.py'
shows all file dependees. However, you need both to keep it accurate.
w
yea, the
dependees json
output format has essentially been replaced with
peek
in later versions
πŸ‘ 1
βœ… 1