high-magician-46188
10/18/2022, 2:09 PMinternal.db
(where internal
is a namespace package).
3. In repo B (which is the mono-repo where I try to integrate Pants) internal.db
is in use and other packages under the internal
namespace are produced.
I think there is a conflict since internal
is partially defined inside the mono-repo and partially outside.
The error I get is of the following form (I get lots of them and they come in pairs:
15:44:04.72 [WARN] The target internal_backoffice/internal/backoffice/__init__.py:../../internal-backoffice-src-sources imports `internal.db`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['//:root#internal-db', 'internal_analytics/internal/__init__.py:../internal-analytics-src-sources', 'internal_athena/internal/__init__.py:../internal-athena-src-sources', 'internal_data_science/internal/__init__.py:../internal-data-science-src-sources', 'internal_logs/internal/__init__.py:../internal-logs-src-sources', ..., 'internal_sqs/internal/__init__.py:../internal-sqs-src-sources'].
Please explicitly include the dependency you want in the `dependencies` field of internal_backoffice/internal/backoffice/__init__.py:../../internal-backoffice-src-sources, 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>.
15:44:04.72 [WARN] Pants cannot infer owners for the following imports in the target internal_backoffice/internal/backoffice/__init__.py:../../internal-backoffice-src-sources:
* internal.db (line: 11)
I’ve tried adding the follwing to the root BUILD
file but it didn’t fix it:
__defaults__({
python_requirements: {
"module_mapping": {
"internal-db": ["internal.db"],
}
}
})
And internal-db
is in Pants’ req file.
I’ll try to setup a repro, but not sure when I’ll be able to…high-magician-46188
10/18/2022, 2:09 PMpolite-garden-50641
10/18/2022, 2:21 PMpython_requirements
module_mapping
attribute to tell pants that the internal package coming from repo A, only exposes the 'internal.db` module/namespace and not the entire internal
ns/package:
python_requirements(module_mapping={"internal": ["internal.db"]})
polite-garden-50641
10/18/2022, 2:21 PMpolite-garden-50641
10/18/2022, 2:24 PMhigh-magician-46188
10/18/2022, 2:25 PMhappy-kitchen-89482
10/18/2022, 3:07 PMinternal
package, so Pants doesn’t know which one to select for dep inference.happy-kitchen-89482
10/18/2022, 3:08 PM//:root#internal-db
happy-kitchen-89482
10/18/2022, 3:08 PMinternal.db
, not internal
, so it should be able to not care about internal
itself, I thinkhappy-kitchen-89482
10/18/2022, 3:09 PMhigh-magician-46188
10/18/2022, 3:10 PMhigh-magician-46188
10/18/2022, 3:15 PMhigh-magician-46188
10/18/2022, 3:28 PMhappy-kitchen-89482
10/18/2022, 4:39 PMhigh-magician-46188
10/19/2022, 6:01 AMnamespace_collision_example
branch.
The README.md
(linked) has the details.
Please LMK if you know how to fix it or if I can do anything to help fix it or to provide more details.
Thanks 🙂high-magician-46188
10/19/2022, 3:52 PMpants package ::
except of the issue with the namespace.
@happy-kitchen-89482, could you take a look at the repro I’ve linked and let me know if it’s a mis-config by me or an uncovered use-case by Pants?
Thanks in advance 🙏happy-kitchen-89482
10/19/2022, 5:28 PMhappy-kitchen-89482
10/19/2022, 6:00 PMdependencies=
?high-magician-46188
10/19/2022, 6:02 PMhappy-kitchen-89482
10/19/2022, 7:54 PMhappy-kitchen-89482
10/19/2022, 7:54 PMhigh-magician-46188
10/20/2022, 6:51 AM