So I'm fairly certain I found a peculiar bug in Pa...
# general
f
So I'm fairly certain I found a peculiar bug in Pants dependency inference, but the code is proprietary and I'm not sure I'd be successful in creating a small sample to reproduce. It only happened to me in one module over our huge monorepo. It's almost assuredly a bug because I wouldn't think the order of
import
lines in a given python module should ever affect its ability to infer.
I could file an issue, but again, I'm not optimistic that I can provide enough relevant information to repro. I've worked around the problem for now (by reordering the imports and disabling isort for that line), but if any Pants devs would like to dig into this, let me know! https://pantsbuild.slack.com/archives/C046T6T9U/p1738699650817799?thread_ts=1738694388.567079&cid=C046T6T9U Eh, nope, it was PEBKAC. Carry on...
f
Do you have the
python-dump-source-analysis
debug goal installed? (Run
pants help goals
and see if it is listed.) if you do, that will dump the raw dependency inference metadata which may provide useful information to help debug.
(It's active in the Pants repository, but I don't see the usual
...debug_goals
backend for it, so I am wondering whether we actually made it visible to users ... )
f
Oh right, someone told me about that the other day. I will try it and get back to you.
Also does
--keep-sandboxes=always
not apply to the
dependents
goal? It's never worked for me.
f
The
dependents
goal does not invoke a process so there is no sandbox ever created.
(Since it can answer the question with just the build graph.)
👍 1
Also you'll want to run
pants python-dump-source-analysis --analysis-flavor=raw_dependency_inference PYTHON_SOURCE_TARGET
to get the most data.
Although seeing the data for both analysis modes will be likely be useful.
f
so I am wondering whether we actually made it visible to users
Yep, just need
pants.backend.experimental.python
. https://www.pantsbuild.org/stable/reference/goals/python-dump-source-analysis
Here's all I see that seems relevant:
Copy code
"email_first": {"lineno": 50, "weak": false}
...
"email_first": {"status": "ImportOwnerStatus.unowned", "address": []},
Interestingly there's no entries for the other two imports (login and mfa) on the import line.
h
Hmm, and what do you see for
email_first
when you rearrange the import order so that it works?
f
Ah interesting. Now it starts with "web.":
Copy code
"web.email_first": {"lineno": 10, "weak": false},
...
"web.email_first": {"status": "ImportOwnerStatus.unambiguous", "address": ["fooserv/web/email_first.py"]}
Literally all I did was move the
from web import email_first, login, mfa
statement from line 50 to line 10 ...
(There are a LOT of imports in this file. The first 50 lines (minus one blank line) are all import statements 🙂 ... this problematic one was the last, on line 50.)
OHHHH
OH NO
I rebased yesterday. There was a conflict in this file and I messed up the manual edit. 🤦
So there was a syntax error at the tail end of the 50 lines of import statements that looked like this:
Copy code
from foo.bar import (
from foo.baz import (
    ...
)
from web import email_first, login, mfa
Sorry for the false alarm. I've been pretty focused on running just pants, and didn't have any linters running to check this for me after I did the rebase. And I've been working at the command line outside my normal IDE environment as well. 🙃
h
OOOOOOF!
Glad you figured that out
f
Thanks! I feel silly, oh well, onward and upward.