adamant-coat-28831
09/01/2022, 7:25 PMadamant-coat-28831
09/01/2022, 7:26 PMadamant-coat-28831
09/01/2022, 7:26 PMmonorepo/
cicd/
BUILD
...
libraries/
BUILD
...
models/
model_1/
BUILD
main.py
model.py
model_2/
BUILD
main.py
model.py
...
pants
pants.toml
adamant-coat-28831
09/01/2022, 7:27 PMmain.py
is identical across model_1
and model_2
.
We started with model_1
and everything ran fine, but when we added model_2 and ran ./pants check ::
we obtained this warning:adamant-coat-28831
09/01/2022, 7:28 PMThe target models/model_1/main.py:lib imports `<http://model.bm|model.bm>`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['models/model_2/model.py:lib', 'models/model_1/model.py:lib'].
Please explicitly include the dependency you want in the `dependencies` field of models/model_1/main.py:lib, 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.12/docs/troubleshooting#import-errors-and-missing-dependencies>.
adamant-coat-28831
09/01/2022, 7:28 PMfrom model import bm
to from .model import bm
.adamant-coat-28831
09/01/2022, 7:28 PMadamant-coat-28831
09/01/2022, 7:28 PMmodels/model_1/main.py: error: Duplicate module named "main" (also at "models/model_2/main.py")
models/model_1/main.py: note: Are you missing an __init__.py? Alternatively, consider using --exclude to avoid checking one of them
adamant-coat-28831
09/01/2022, 7:29 PM__init__.py
scripts to model_1 and model_2.adamant-coat-28831
09/01/2022, 7:30 PMbitter-ability-32190
09/02/2022, 2:58 PMmypy
doesn't know you aren't using implicit namespace packages so it warns.rich-london-74860
09/02/2022, 3:48 PMrich-london-74860
09/02/2022, 4:34 PMmodels/model_1
using MLFlow Project, which does not seem to handle relative imports. This means that we cannot use relative imports in MLFlow Projects, where the code actually runs, and we can’t use implied imports in Pants. Does that means we just can’t use MLFlow Project and Pants?bitter-ability-32190
09/02/2022, 4:34 PMrich-london-74860
09/02/2022, 4:35 PMBUILD
?bitter-ability-32190
09/02/2022, 4:35 PMpants.toml
rich-london-74860
09/02/2022, 4:36 PMmarker_filenames = ["setup.cfg", "MLProject"]
rich-london-74860
09/02/2022, 4:37 PMsetup.cfg
to identify our libraries
MLProject
to identify our MLFlow Projectsbitter-ability-32190
09/02/2022, 4:37 PMadamant-coat-28831
09/02/2022, 4:37 PMbitter-ability-32190
09/02/2022, 4:38 PMfrom model_1.model ...