Here's a strange one. I'm running into an issue wh...
# general
p
Here's a strange one. I'm running into an issue where a directory called
benchmarks
in the project root is mysteriously causing an attempt to
run
a
.py
file to fail. Details in thread.
I've made a minimal reproduction repo here: https://github.com/jake-normal/package-name-issue-repro
Copy code
pants run benchmarks/example.py # This will fail with "ImportError: No module named benchmarks.example"
mv benchmarks benchmark
pants run benchmark/example.py  # this will succeed
The only instance of the string
benchmarks
in the entire project is in the directory name itself
as far as I can tell, that
ragas
import is required
also as far as I can tell, benchmarks can be renamed to anything else and the
.py
target invocation will succeed.
(Also, huge thanks to the pants community for being so helpful in the past. I've learned a ton so far with your help. Hoping to be able to reciprocate when my mental model solidifies!)
w
Why
# type: ignore
?
p
Ah, sorry, copied out of another repo
Same behavior when removed
w
I wonder if somehow you're dep inferring into the ragas/tests/benchmarks or something
p
that is my only hunch, yeah
they do seem to do some benchmarking, though I don't see any reference to a
benchmarks
dir
I did similar inspection of the
pytest-benchmark
repo, since they rely on it
w
I'm just assuming that because it's the only thing off the top of my head that would make any logical sense
p
(oh now I reread your comment and noticed you pointed out
tests/benchmarks
)
w
Especially since, as soon as you remove the import - the problem goes away... Still, weird.
p
Yeah.
Any idea for how I might probe / work around that? I'm puzzled. (I'm trying not to open an annoying "rename benchmarks -> benchmark" PR)
This sanity check has already been helpful in any case – thanks for looking at it.
This was... hard to track down.
w
I'd have to give it some thought, going afk for a few hours
Some amount of introspection or --transitive checks should find something, but I'm not sure which commands yet. Also, --keep-sandboxes=always can be handy
p
Cool, hugely appreciate it
w
One other thing off the top of my head, what happens if you make an explicit pex of that example.py file, and call run on that target - I'm curious if there is some shenanigans happening while trying to run a single file
p
looking
Copy code
diff --git a/benchmarks/BUILD b/benchmarks/BUILD
index db46e8d..63c5de0 100644
--- a/benchmarks/BUILD
+++ b/benchmarks/BUILD
@@ -1 +1,3 @@
 python_sources()
+
+pex_binary(name="hi", entry_point="example.py")
then:
Copy code
pants run benchmarks:hi
still fails
going afk myself, back tomorrow. Thanks for your eyes!