bright-pilot-85305
11/10/2022, 4:08 PMbright-pilot-85305
11/10/2022, 4:08 PMmonorepo
├── application
│ ├── BUILD
│ ├── README.md
│ ├── application
│ │ ├── BUILD
│ │ ├── __init__.py
│ │ └── main.py
│ ├── poetry.lock
│ ├── pyproject.toml
│ └── tests
│ ├── BUILD
│ ├── __init__.py
│ └── test_application.py
├── library
│ ├── BUILD
│ ├── README.md
│ ├── library
│ │ ├── BUILD
│ │ ├── __init__.py
│ │ └── main.py
│ ├── poetry.lock
│ ├── pyproject.toml
│ └── tests
│ ├── BUILD
│ ├── __init__.py
│ └── test_library.py
├── pants
├── pants.toml
└── service
├── BUILD
├── README.md
├── poetry.lock
├── pyproject.toml
├── service
│ ├── BUILD
│ ├── __init__.py
│ └── main.py
└── tests
├── BUILD
├── __init__.py
└── test_service.py
bright-pilot-85305
11/10/2022, 4:09 PM[GLOBAL]
pants_version = "2.14.0"
backend_packages = [
"pants.backend.python",
"pants.backend.docker",
"pants.backend.python.lint.bandit",
"pants.backend.python.lint.black",
"pants.backend.python.lint.flake8",
"pants.backend.python.lint.isort",
"pants.backend.python.typecheck.mypy",
]
[python-bootstrap]
search_path = ["/opt/homebrew/bin/"]
[source]
root_patterns = [
"/application",
"/library",
"/service",
]
[anonymous-telemetry]
enabled = true
repo_id = "3063a0b6-cb3b-40a4-8221-2641e0ae0df4"
polite-garden-50641
11/10/2022, 4:16 PMbright-pilot-85305
11/10/2022, 4:18 PMfrom pyspark.sql import DataFrame as SparkDataFrame, SparkSession
import pandas as pd
from library.main import Run
Service
from fastapi import FastAPI
from library.main import Run, get_run
from uuid import UUID
Library
from pydantic import BaseModel
from pathlib import Path
from uuid import UUID
polite-garden-50641
11/10/2022, 4:26 PM./pants dependencies <file path>
on the service file you mentioned above (the one with from library.main import Run, get_run
) ?bright-pilot-85305
11/10/2022, 4:29 PM❯ ./pants dependencies service/service/main.py
09:28:10.21 [INFO] Initializing scheduler...
09:28:10.34 [INFO] Scheduler initialized.
library/library/main.py
service/service/__init__.py
service:poetry#fastapi
For application
❯ ./pants dependencies application/application/main.py
application/application/__init__.py
For library
❯ ./pants dependencies library/library/main.py
09:28:41.34 [WARN] The target library/library/main.py imports `pydantic.BaseModel`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['library:poetry#pydantic', 'service:poetry#pydantic'].
Please explicitly include the dependency you want in the `dependencies` field of library/library/main.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>.
09:28:41.35 [WARN] Pants cannot infer owners for the following imports in the target library/library/main.py:
* pydantic.BaseModel (line: 1)
If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see <https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies> for common problems.
library/library/__init__.py
polite-garden-50641
11/10/2022, 4:35 PMbright-pilot-85305
11/10/2022, 4:37 PMapplication/BUILD
is
poetry_requirements(
name="poetry",
)
application/application/BUILD
is
python_sources()
The pattern is the same for library
and service
bright-pilot-85305
11/10/2022, 4:40 PMpolite-garden-50641
11/10/2022, 4:41 PM./pants dependencies libary:poetry
(basically on the poetry_requirements
that has the pydantic req should show u if pants sees that dep or not.bright-pilot-85305
11/10/2022, 4:42 PM❯ ./pants dependencies libary:poetry
09:42:00.17 [ERROR] 1 Exception encountered:
ResolveError: The file or directory 'libary' does not exist on disk in the workspace, so the address 'libary:poetry' from CLI arguments cannot be resolved.
polite-garden-50641
11/10/2022, 4:43 PM./pants list ::
to get a list of targets for the project, this will tell you how pants see that specific target.bright-pilot-85305
11/10/2022, 4:44 PMlibrary
was misspelled abovebright-pilot-85305
11/10/2022, 4:44 PM❯ ./pants dependencies library:poetry
library/pyproject.toml:poetry
library:poetry#bandit
library:poetry#black
library:poetry#flake8
library:poetry#ipython
library:poetry#isort
library:poetry#mypy
library:poetry#pydantic
library:poetry#pytest
bright-pilot-85305
11/10/2022, 4:45 PM❯ ./pants list ::
application:poetry
application:poetry#pandas
application:poetry#pyspark
application:poetry#pytest
application/pyproject.toml:poetry
application/application:application
application/application/__init__.py
application/application/main.py
application/tests:tests
application/tests/test_application.py
library:poetry
library:poetry#bandit
library:poetry#black
library:poetry#flake8
library:poetry#ipython
library:poetry#isort
library:poetry#mypy
library:poetry#pydantic
library:poetry#pytest
library/pyproject.toml:poetry
library/library:library
library/library/__init__.py
library/library/main.py
library/tests:tests
library/tests/test_library.py
service:poetry
service:poetry#bandit
service:poetry#black
service:poetry#fastapi
service:poetry#flake8
service:poetry#ipython
service:poetry#isort
service:poetry#json-logging
service:poetry#mypy
service:poetry#pydantic
service:poetry#pytest
service/pyproject.toml:poetry
service/service:service
service/service/__init__.py
service/service/main.py
service/tests:tests
service/tests/test_service.py
polite-garden-50641
11/10/2022, 4:46 PMpolite-garden-50641
11/10/2022, 4:46 PM09:28:41.34 [WARN] The target library/library/main.py imports `pydantic.BaseModel`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['library:poetry#pydantic', 'service:poetry#pydantic'].
polite-garden-50641
11/10/2022, 4:47 PMpydantic
pants doesn't know from which one of those it should get pydantic
bright-pilot-85305
11/10/2022, 4:49 PMpolite-garden-50641
11/10/2022, 4:50 PMpoetry_requirements
target in one of those and try again.bright-pilot-85305
11/10/2022, 4:54 PMbright-pilot-85305
11/10/2022, 4:55 PMbright-pilot-85305
11/10/2022, 4:56 PMhappy-kitchen-89482
11/10/2022, 11:22 PMhappy-kitchen-89482
11/10/2022, 11:23 PMpoetry_requirements()
target in a BUILD file) we can read poetry-style requirements from a pyproject.toml.happy-kitchen-89482
11/10/2022, 11:24 PMpydantic
in multiple of those, then you’re introducing multiple possible sources that could provide pydantic
, so Pants doesn’t know which one you mean.happy-kitchen-89482
11/10/2022, 11:25 PMhappy-kitchen-89482
11/10/2022, 11:25 PMhappy-kitchen-89482
11/10/2022, 11:26 PMhappy-kitchen-89482
11/10/2022, 11:26 PMbright-pilot-85305
11/10/2022, 11:26 PMhappy-kitchen-89482
11/10/2022, 11:26 PMhappy-kitchen-89482
11/10/2022, 11:26 PMhappy-kitchen-89482
11/10/2022, 11:26 PMbright-pilot-85305
11/10/2022, 11:34 PMhappy-kitchen-89482
11/11/2022, 12:29 AMhappy-kitchen-89482
11/11/2022, 12:29 AMhappy-kitchen-89482
11/11/2022, 12:30 AM