acoustic-garden-40182
03/15/2023, 8:09 PM/src/my_app/my_app.py
/src/my_app/utils.py
/tests/test_my_app.py
my_app.py
from utils import func1, func2, func3
test_my_app.py
from my_app.my_app import function_to_test
pants.toml
[source]
root_patterns = [
".",
"/cdk", # AWS CDK stuff in Python, not relevant to this
"/src",
"/tests",
]
/src/my_app/BUILD
python_sources()
pants dependees src/my_app/utils.py
20:06:56.42 [WARN] Pants cannot infer owners for the following imports in the target src/my_app/my_app.py:
* utils.func1 (line: 8)
* utils.func2 (line: 8)
* utils.func3 (line: 8)
pants dependencies src/my_app:my_app
src/my_app/my_app.py
src/my_app/utils.py
curved-television-6568
03/15/2023, 8:16 PMfrom my_app.utils import func1, func2, func3
acoustic-garden-40182
03/15/2023, 8:18 PMcurved-television-6568
03/15/2023, 8:23 PMcurved-television-6568
03/15/2023, 8:25 PMacoustic-garden-40182
03/15/2023, 8:29 PMARG FUNCTION_DIR="/function"
FROM ubuntu:20.04
RUN ... # install some dependencies etc.
ARG FUNCTION_DIR
COPY ./my_app.py ${FUNCTION_DIR}/
COPY ./utils.py ${FUNCTION_DIR}/
COPY ./entrypoint.sh /entrypoint.sh
WORKDIR ${FUNCTION_DIR}
ENTRYPOINT [ "/entrypoint.sh" ] # python my_app.py
It works fine if I do from utils import ...
but not with from my_app.utils import ...
acoustic-garden-40182
03/15/2023, 8:30 PMacoustic-garden-40182
03/15/2023, 8:31 PMpython my_app.py
locally as wellcurved-television-6568
03/15/2023, 8:32 PMmy_app
for the sourcescurved-television-6568
03/15/2023, 8:33 PMCOPY my_app $FUNCTION_DIR/
or even to package the whole thing up as a โpexโ and run that.curved-television-6568
03/15/2023, 8:34 PMacoustic-garden-40182
03/15/2023, 8:35 PMCOPY my_app $FUNCTION_DIR/
my entrypoint script should run python my_app/my_app.py
is that correct?curved-television-6568
03/15/2023, 8:36 PMcurved-television-6568
03/15/2023, 8:36 PMacoustic-garden-40182
03/15/2023, 8:36 PMcurved-television-6568
03/15/2023, 8:37 PMacoustic-garden-40182
03/15/2023, 9:18 PMacoustic-garden-40182
03/15/2023, 9:19 PM