early-jelly-10468
01/05/2023, 6:21 PMroot
├── service_1
│ ├── app_code_1/
│ │ └── module_123.py
│ ├── tests/
│ │ ├── conftest.py
│ │ └── test_app_code_1
│ │ └── test_module_123.py
│ ├── conftest.py
│ └── requirements.txt
├── service_2
│ ├── app_code_1/
│ │ └── module_123.py
│ ├── tests/
│ │ ├── conftest.py
│ │ └── test_app_code_1
│ │ └── test_module_123.py
│ ├── conftest.py
│ └── requirements.txt
└── n...
Our code is laid out in this manner (omitting the pants files) with each service in its own directory and a separate directory for tests and the application code.
If I run a ./pants test ::
it successfully picks up all the tests from each service, but they all fail due to missing 3rd party imports. I ran ./pants --filter-target-type=python_requirement list ::
and it looks like it is finding all the imports from the requirements.txt
projects/service_1:reqs#pytest
projects/service_1:reqs#etc
n...
Makes me think something about how our code is organized is preventing the tests from running using the requirements file. I was also expecting that I would be able to do something like ./pants test /service_1/:
but that does not pickup the test directory contained inside the service, further making me think the organization is messing it up.
Any guidance or direction would be helpful, I've been poking around the settings/configurations for about a day and haven't made any headway 🙂. Thanks for anyone's timeplain-night-51324
01/05/2023, 6:30 PMplain-night-51324
01/05/2023, 6:32 PMwitty-crayon-22786
01/05/2023, 6:42 PMearly-jelly-10468
01/05/2023, 7:06 PMSeems like they all follow this general format
The target {dir}:tests imports `{one of my functions}`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: [list of places]
Am I correct in thinking this is being caused by the same named function/import path existing in multiple of my services?witty-crayon-22786
01/05/2023, 7:07 PMwitty-crayon-22786
01/05/2023, 7:08 PMearly-jelly-10468
01/05/2023, 7:12 PMroot/service_1/module_1.py/function_1
root/service_2/module_1.py/function_1
Because inside a file root/service_2/module_2.py
the import statement is just from module_1 import function_1
.
Correct?early-jelly-10468
01/05/2023, 7:22 PMservice_1/
for everything in service_2/
? The logs make it seem like I'd have to go write out the dependencies in every single build file with an ambiguous import (there are a lot 😞)curved-manchester-66006
01/05/2023, 7:29 PM./pants roots
show?early-jelly-10468
01/05/2023, 7:33 PM.
, i messed with it some and got it to show all the different services because I thought that might have been part of the problem. After using a marker file I got it to read:
.
/root/service_1
/root/service_2
...n
Did not seem to impact the issue thoughcurved-manchester-66006
01/05/2023, 7:45 PMearly-jelly-10468
01/05/2023, 7:45 PMhappy-kitchen-89482
01/05/2023, 7:51 PMhappy-kitchen-89482
01/05/2023, 7:52 PMwitty-crayon-22786
01/05/2023, 8:04 PMearly-jelly-10468
01/05/2023, 8:09 PMwitty-crayon-22786
01/05/2023, 8:12 PMearly-jelly-10468
01/05/2023, 8:13 PMwitty-crayon-22786
01/05/2023, 8:14 PMhappy-kitchen-89482
01/05/2023, 8:41 PMwitty-crayon-22786
01/05/2023, 9:14 PMhappy-kitchen-89482
01/05/2023, 9:47 PMearly-jelly-10468
01/05/2023, 9:50 PMhappy-kitchen-89482
01/06/2023, 11:12 AMhappy-kitchen-89482
01/06/2023, 11:13 AMearly-jelly-10468
01/06/2023, 6:30 PMpricing
└── order
└── api.py
invoicing
└── order
└── api.py
For N number of things. Code is totally different but the context is all around the same business object so thats how it was organizedhappy-kitchen-89482
01/06/2023, 7:11 PM