hey folks, is there a way to debug dependency infe...
# general
c
hey folks, is there a way to debug dependency inference for python? I've got an import statement in a test that isn't generating the corresponding dependency
1
h
So you don’t see it if you run
./pants dependencies path/to/test.py
?
One thing to check is whether the dependency’s source root is correctly listed in
./pants roots
c
Ohhh, it's almost certainly that the roots are messed up. I had a root at "/a/b/x" and "/c/d/x", but mypy was complaining that the module "x" appeared multiple times (fair). So I modified the modules to use the full path "from a.b.x import ...", But didn't remove the roots. I'll give that a shot tomorrow. More generally, is the a way to enable debug logging for dependency inference? Ideally something like "found import statement ... , Resolves to target ...". My usual
-ldebug
only gave a single line for the process.
h
Alas I don’t think so, but that would be good to add to
-ldebug
Oh, have you tried
-ltrace
?
b
The dependency inference script is embedded in pants and dependency-less. Sometimes to debug it I just run it directly. Take note of the comment at the top for how to run it (it expects from env vars) https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/python/dependency_inference/scripts/dependency_parser_py
c
yep, that was it. removing the (nested) extraneous roots.
-ldebug
and
-ltrace
didn't add anything, just progress notifications. Manually running dependency_parser_py does resolve the import correctly, so I think it's afterward that it gets dropped.
b
@careful-address-89803 please feel free to also open an issue, to request the additional info in
-ldebug
.
c
I'm interested in working on this and getting familiar with the mechanics of dependency inferrence. I'm not sure where/how to hook into this.
h
@careful-address-89803 I love the idea you propose, and that would be awesome to have your help! How do you feel about what the next steps are, based on our replies? I'm happy to write out more clear tips if that would be useful
c
Do we see collecting the existing debug goals into a common goal to be a prerequisite step? and then we can plug python into that?
h
I don't think it needs to be a prereq step. I think JVM users often != Go users != Python users, no need to bundle them together
👍 1