rapid-bird-79300
01/19/2023, 5:18 PMpants.backend.python.dependency_inference.rules.UnownedDependencyError: Pants cannot infer owners for the following imports in the target app/monolith/something/models.py:
* psycopg2 (line: 8)
This makes sense because I added a new pyproject.toml for the new project but curious if there a way around this without impacting the monolith dependencies.rapid-bird-79300
01/19/2023, 5:21 PMrapid-bird-79300
01/19/2023, 5:22 PMhappy-kitchen-89482
01/19/2023, 5:36 PMrapid-bird-79300
01/19/2023, 5:37 PMrapid-bird-79300
01/19/2023, 5:39 PM[resolves]
new-project = "src/python/new-project/poetry.lock"
rapid-bird-79300
01/19/2023, 5:40 PMrapid-bird-79300
01/19/2023, 5:41 PMhappy-kitchen-89482
01/19/2023, 6:02 PMhappy-kitchen-89482
01/19/2023, 6:02 PMhappy-kitchen-89482
01/19/2023, 6:03 PMhappy-kitchen-89482
01/19/2023, 6:04 PMhappy-kitchen-89482
01/19/2023, 6:04 PMrapid-bird-79300
01/19/2023, 6:04 PMrapid-bird-79300
01/19/2023, 6:04 PMhappy-kitchen-89482
01/19/2023, 6:04 PMrapid-bird-79300
01/19/2023, 6:05 PMrapid-bird-79300
01/19/2023, 6:05 PMrapid-bird-79300
01/19/2023, 6:12 PMenable_resolves = true
resolves = """
{
"monolith": "poetry.lock",
"test-selection": "src/python/test-selection-api/poetry.lock"
}
"""
seeing this conflict:
11:09:22.51 [WARN] The target app/monolith/something.py imports `psycopg2`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['//:poetry#psycopg2-binary', 'src/python/test-selection-api:poetry#psycopg2'].
Please explicitly include the dependency you want in the `dependencies` field of app/monolith/something.py, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.
Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to <https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies>.
11:09:22.51 [WARN] The target app/monolith/something.py imports `psycopg2`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['//:poetry#psycopg2-binary', 'src/python/test-selection-api:poetry#psycopg2'].
rapid-bird-79300
01/19/2023, 6:12 PM__defaults__(all=dict(resolve="monolith"))
rapid-bird-79300
01/19/2023, 6:31 PMrapid-bird-79300
01/19/2023, 6:35 PM[python]
enable_resolves = true
resolves = """
{
"python-default": "default.lock",
"test-selection": "src/python/test-selection/test-selection.lock"
}
"""
I added both python-default
and test-selection
. The first python-default
is a place holder to make pants happy (since the default "3rdparty/python/default.lock" does not exists anyway, it shouldn't matter)
2. Set the build defaults for the test-selection project to use test-selection
resolves
This is important because you must mark poetry_requirements
to their correct resolve. For example
poetry_requirements(
name="poetry",
resolve="test-selection"
)
This is important to do priori to generating the resolve lock.
3. Generate a lock file for the new project
./pants generate-lockfiles --resolve=test-selection
After doing all the above, the monolith can now infer dependencies as it did before. This means we can work on a new project without impact the monolithrapid-bird-79300
01/19/2023, 6:35 PMrapid-bird-79300
01/19/2023, 6:36 PMhappy-kitchen-89482
01/19/2023, 8:02 PMhappy-kitchen-89482
01/19/2023, 8:03 PMrapid-bird-79300
01/19/2023, 10:26 PM