alert-beard-13327
12/03/2024, 5:35 PMalert-beard-13327
12/03/2024, 5:45 PMalert-beard-13327
12/03/2024, 5:46 PMalert-beard-13327
12/03/2024, 5:50 PMalert-beard-13327
12/03/2024, 5:56 PMbroad-processor-92400
12/03/2024, 6:50 PMimport healthdash…
which would imply that src
itself should be the root, not src/healthdash
(via src/*
).
The source roots contain directories that are the libraries/importable objects, they aren’t the importable objects themselves.
Can you try changing the source roots to remove the globs?alert-beard-13327
12/03/2024, 7:32 PMpants list
with that change unfortunately.alert-beard-13327
12/03/2024, 8:23 PMapp/app1/app1/__init__.py
vs app/app1/__init__.py
? Does pants get confused about the dependency tree/is something incorrect in my BUILD/source roots?alert-beard-13327
12/03/2024, 8:24 PMtailor ::
, I get two BUILD
files, one inside of `app1`(e.g. next to pyproject.toml
, and one inside of app1/app1
(e.g. next to my __init__.py
), though it seems to build fine if I remove the internal BUILD file.broad-processor-92400
12/03/2024, 8:46 PMpants list
output to change based on dependency inference. That is listing the individual targets rather than any metadata about them.
for getting this working, maybe something like pants dependencies path/to/broken/file.py
would be better.
(I acknowledge your other question/note, but I’m on mobile at the moment so can’t digest/respond yet)broad-processor-92400
12/04/2024, 10:03 PMIs it possible I'm having so many issues because everything is structured likePants should be able to work with this, but you might need your source roots to bevsapp/app1/app1/__init__.py
? Does pants get confused about the dependency tree/is something incorrect in my BUILD/source roots?app/app1/__init__.py
["src", "app/*"]
, i.e. src/a/b/c.py
is imported as import a.b.c
and app/a/b/c.py
is imported as import b.c
I notice also on a blank repository with a similar structure, runningYeah, by default Pants will have one BUILD file per directory, with targets just globbing the files within that directory, rather than a "top-level" BUILD file with, I get twotailor ::
files, one inside of `app1`(e.g. next toBUILD
, and one inside ofpyproject.toml
(e.g. next to myapp1/app1
), though it seems to build fine if I remove the internal BUILD file.__init__.py
**/*.py
-style recursive globs. Both should work okay.straight-alligator-6122
12/05/2024, 8:20 AMalert-beard-13327
12/06/2024, 8:35 PMalert-beard-13327
12/06/2024, 8:41 PMalert-beard-13327
12/06/2024, 9:34 PMpoetry_requirements(
name="poetry",
)
pex_binary(
name="healthdash_app",
script="streamlit",
args=["run", "app/healthdash/healthdash/NOC_Pod_Overview.py"],
execution_mode="venv",
dependencies=[
":poetry", "//app/healthdash/healthdash/NOC_Pod_Overview.py",
],
)
My assumption would be that it attempts to run the NOC_Pod_Overview that exists inside the PEX file, but instead I have to run it in a way that the relative path I provide as args exists, meaning, its using the repo version of that file and not the... bundled/packaged version? Which doesn't make sense to me.broad-processor-92400
12/08/2024, 10:17 PMalert-beard-13327
12/09/2024, 8:40 PM./dist/app-healthdash/healthdash.pex
from anywhere except the repo root, it cant find the file.
.
└── monorepo/
├── .github/
│ └── workflows/
│ ├── build_app1.yaml
│ └── build_app2.yaml
├── app/
│ └── healthdash/
│ ├── healthdash/
│ │ ├── NOC_Pod_Overview.py
│ │ └── __init__.py
│ ├── BUILD
│ ├── Dockerfile
│ ├── pyproject.toml
│ └── poetry.lock
├── dist/
│ └── healthdash-app/
│ └── healthdash-app.pex
└── pants.toml
Meaning, lets say I cd into dist
and run the pex from that directory, it can't find the .py
file, but if I go up a directory, e.g. monorepo
, it runs, but its not using the bundled version of that file, its using the actual file that exists in app/healthdash/healthdash/
broad-processor-92400
12/09/2024, 9:38 PMstreamlit
args are being consumed relative to the process's current working directory, while the files in the PEX will be placed in some "random" venv. That is, the pex isn't run from where its own sources are.
I think others have encountered this, but I'm not sure how they solved it (I personally haven't used streamlit). Maybe try digging through a slack search for streamlit?broad-processor-92400
12/09/2024, 9:39 PMstraight-alligator-6122
12/10/2024, 6:37 PMstraight-alligator-6122
12/10/2024, 6:39 PMalert-beard-13327
12/10/2024, 10:21 PMalert-beard-13327
12/10/2024, 10:22 PMbroad-processor-92400
12/10/2024, 10:48 PM