Hi everyone, I'm new to Pants and I'm having some ...
# general
c
Hi everyone, I'm new to Pants and I'm having some trouble with setting up the resolves. I would appreciate some advice! In my root dir, I have two submodules, let's call them
project
and
utils
. Both contain python code and have their own requirements.txt files.
project/requirements.txt
includes utils' requirements:
-r ../utils/requirements.txt
since project's code imports utility functions. This setup has been working fine (I have been able to run
pants test
command) until I decided to set up the resolves for the two submodules. When I run
pants test
, I'm constantly getting the following error:
ModuleNotFoundError: No module named utils
. This comes from one of the `project`'s test scripts which tries to import a function from the utils directory. I have been able to include `utils`' dependencies to `project`'s resolve by using the
parametrize
keyword, but I'm unable to include the
utils
submodule itself. Thanks in advance for any help!
r
Hey! Most probably a source root issue. Can you tell us what is/are your source roots?
c
The Pants source is at the root dir,
root_patterns=["/"]
. Is this what you meant?
r
Yeah
c
This is intended so that, in the `project`'s python files, I can
from utils import ....
r
That root pattern looks fine then. Now I guess somewhere your resolves' parametrization isn't working. What resolve do you use for the tests?
c
In
project/tests/BUILD
I have
python_tests
with
resolve="project"
and
dependencies=["utils:reqs"]
r
I am out of solutions. Let's wait for someone from pants core members who might have better idea
h
Hi! It sounds like you want a single resolve for both sets of requirements (since one is a strict subset of the other)?
How are you setting up the resolves in pants.toml?
c
Hi Benjy, I actually need separate resolves to acomodate submodules that will be added in the future. But I managed to solve my problem by adding
utils:utils
to project's test dependencies. Thanks!
h
Ah, cool!
Can you explain more about the separate resolves? Usually you only need separate resolves when the two are incompatible, but in your case one is a subset of the other, so they would have to be compatible?
c
Sure! What I'm trying to do is to gradually move to a monorepo architecture from multiple repositories. In the example I provided there are only two submodules whose requirements are compatible, but in the future I will be adding more that might be conflicting, so I wanted to have a robust setup already.
h
Makes sense!
In the long run you might benefit from consolidating down to fewer resolves (1 is best!), but this is a good way to start merging repos!