Kim Pevey
08/18/2021, 3:21 PMFailed to load and execute Flow's environment: ValueError('Flow is not contained in this Storage')
I’m not sure how to debug this. What are the possible causes of this error?Kevin Kho
Kim Pevey
08/18/2021, 3:25 PMKim Pevey
08/18/2021, 3:26 PMGCS
Storage objectKevin Kho
Kim Pevey
08/18/2021, 4:05 PMKevin Kho
conda
or pipenv
or something else?Kim Pevey
08/18/2021, 4:31 PMJohn Lee
08/18/2021, 4:37 PMactivating environments in a container is also trickyI agree it is tricky 🙂 We are using conda. It's a large set of dependencies that we have to manage elsewhere with conda so it would be great if we could use the same here.
Kevin Kho
John Lee
08/18/2021, 4:41 PMJohn Lee
08/20/2021, 9:14 AM[FATAL tini (7)] exec prefect failed: No such file or directory
From that I inferred that the environment was not activated (because we have prefect in our environment. Based on the link you sent I modified the container. I extended it slightly based on this table to accommodate /bin/sh, both interactive and login, as I believe the bourne shell is being used due to this line. Here are the relevant lines of our dockerfile for this:
...
ENV CONDA_ENV=myenv
SHELL ["/bin/bash", "--login", "-c"]
# Make RUN commands and the end containers use the new environment
# See <https://en.wikipedia.org/wiki/Unix_shell#Configuration_files>:
RUN export SETUP=". /opt/conda/etc/profile.d/conda.sh && conda activate ${CONDA_ENV}"; \
for f in ~/.profile ~/.bashrc ~/.shrc /etc/profile /etc/bash.bashrc /etc/sh.shrc ; do \
echo "$SETUP" >> $f; \
done
ENV ENV="/etc/profile"
...
Our image should now be robust against the entrypoint or command being overwritten and /bin/sh being used but we are still getting the same error. Either there is a silly error somewhere (which I will try to hunt down over the coming hours) or env variables are completely overwritten in the container. Is there a way I can debug this locally to see changes made to the image before it is used or perhaps the container as it is launched? I don't have a handle on how I should go about debugging this sort of error.John Lee
08/20/2021, 10:14 AM$docker run --rm -ti cba /bin/sh -c prefect
/bin/sh: 1: prefect: not found
Or with tini:
docker run --rm -ti --init -e TINI_SUBREAPER="" cba /bin/sh -c prefect
It seems the conda activation is not working fully with /bin/sh:
$ docker run --rm -ti cba /bin/sh
/bin/sh: 5: /opt/conda/envs/Colombia/etc/conda/activate.d/activate-binutils_linux-64.sh: Syntax error: "(" unexpected
The above doesn't seem to stop the "Colombia" environment being successfully activated when I set the shell as the entrypoint though...
$ docker run --rm -ti --entrypoint /bin/sh cba
/bin/sh: 5: /opt/conda/envs/Colombia/etc/conda/activate.d/activate-binutils_linux-64.sh: Syntax error: "(" unexpected
(Colombia)
Perhaps "set -e" is being used somewhere that prevents the environment from being activated in our desired usecase.John Lee
08/20/2021, 1:54 PMKevin Kho
John Lee
08/20/2021, 2:10 PMcondaforge/mambaforge:4.10.3-1
Kevin Kho
John Lee
08/20/2021, 2:25 PMZanie
Zanie
DockerRun
and a docker agent on your own machine, you should be able to disable the auto_remove
and inspect the container after it has finished.Zanie
from prefect import Flow
from prefect.run_configs import DockerRun
from prefect.storage import Docker
with Flow("test-docker") as flow:
pass
flow.storage = Docker()
flow.run_config = DockerRun(host_config=dict(auto_remove=False))
Zanie
prefect register -p flow.py --project test
prefect agent docker start --label run-here
prefect run --name test-docker --label run-here --run-name test-docker-run
docker inspect test-docker-run
Zanie
--disable-job-deletion
flag on prefect agent kubernetes start
so you can inspect the job specZanie
John Lee
08/20/2021, 3:44 PM