Hey all :wave: Is there a way to visualise the who...
# general
s
Hey all πŸ‘‹ Is there a way to visualise the whole dep graph and/or which dep is pulling another one? e.g.
Copy code
% npm ls react

app@0.1.0
β”œβ”€β”¬ @auth0/auth0-react@1.10.1
β”‚ └── react@18.2.0 deduped
β”œβ”€β”¬ @emotion/react@11.10.4
β”‚ β”œβ”€β”¬ @emotion/use-insertion-effect-with-fallbacks@1.0.0
β”‚ β”‚ └── react@18.2.0 deduped
...
l
Does this help?
πŸ‘€ 1
s
Hey thanks for the answer πŸ™‚ How would you use paths? e.g.
Copy code
% pants paths --paths-from=3rdparty/python:aws#botocore --paths-to=./src/lambda/handler.py

[]
I've also tried using
dependents
but is not clear to me how that works
What I'm trying to solve is understanding which
import
in
src/lambda/handler.py
is pulling in
botocore
For context, there is a target
src/lambda:handler
l
I don’t think it points to a specific line. For
dependents
maybe look at:
Copy code
pants dependents 3rdparty/python:aws#botocore
first, so you pick up on the direct dependents of the library. Then add
--transitive
. TBH I haven’t played with
paths
yet.
πŸ‘ 1
πŸ™ 1
hmmm maybe there is a bug with
paths
… If I put the same target for
from
and
to
I get the path as a result. Which is expected. But I put one of the results of
dependents
as the
to
I get an empty list…
s
Yeah I played a bit with it but eventually gave up - we found a fix someway... https://blog.pantsbuild.org/visualize-your-dependencies-with-graphmyrepo/ I guess there must be a way to tap on the Pants API and pull out the graph but I can't see an easy way to look the DAG from the CLI
e
The
paths
and
dependants
goal are 1st party only. They stop at the boundaries of the repo and do not traverse into 3rdparty deps.
πŸ‘ 1
@strong-xylophone-41556, have you enabled resolves?: https://www.pantsbuild.org/docs/reference-python#enable_resolves If so the information is all in your lock file.
s
Hey @enough-analyst-54434 thanks Yes we have enabled resolves and I can see a lock file Although trying to understand why something is pulled by what is not the easiest Monday morning that I can think about πŸ˜„
e
Just look at the
"requires_dists"
lists and work backwards. For example, why does Pants itself depend on sniffio? Because anyio depends on it: https://github.com/pantsbuild/pants/blob/74127491f69e698bf9243c6af0a02c8ef42d9080/3rdparty/python/user_reqs.lock#L105 and starlette depends on anyio: https://github.com/pantsbuild/pants/blob/74127491f69e698bf9243c6af0a02c8ef42d9080/3rdparty/python/user_reqs.lock#L1649, etc...
πŸ‘ 1
So, not ergonomic, but the data is all there in gory detail.
πŸ’― 1
s
I'll have a fun time parsing that JSON at some point Thanks alot
e
With the npm example you may realize the problem that has slowed this style feature a bit, in Pants in general it needs to work across ecosystems for JS, Python, Go, etc. Each has there own dependency system for 3rdparty.
Currently Pants is 3rdparty dep dumb and just has the 3rdparty tool do the resolving (coursier for JVM, Pex (which uses Pip) for Python, etc.).
Here is the old tracking issue: https://github.com/pantsbuild/pants/issues/13283
s
Admittedly, I'm still wrapping up my head around Pants which seems BTW an incredibly useful tool... Surely, there is an argument in saying that a general sensible abstraction for a dependency graph is an acyclical graph, which could be visualised in a tree view? Or is that a wrong assumption?
Thanks for the detailed info though
e
It's not a question of can it be done, it's a question of time and effort only. All volunteer, not a paid product.
πŸ’― 1
The graph my repo tool you linked was by a paid-for company that folded in May exactly because it could find no way to get this sort of stuff paid for by devs or the companies they work for.
πŸ‘ 1
h
Generally yes, modeling and displaying transitive 3rdparty deps would be useful, and questions like yours pop up from time to time. As John says, it's a matter of someone being motivated enough to pick up the mantle and do the work.
s
Is that a good task to play with Rust or is Rust learning curve to steep to start from there? I learned to "talk" few languages in a relatively small amount of time and can be relatively "fluent" to each one, and have experienced the blessing GPT models can sometimes be in diving into a new one, but I'm also aware that Rust can be quite a head-hammering experience... What would be your suggestion?
e
This is all totally implemented above the Rust engine in Python rules.
h
Yep, can be done entirely in Python
It's mostly a matter of modeling the data in a generic way
And then implementing that model for a domain-specific backend (python, JVM, Go, etc)
s
πŸ‘