0

When using docker as storage, in the call as below:

prefect register --project yourproject -p yourflow.py

It seems that perfect creates a tmp{randomNumber} folder and puts healthcheck.py and a Dockerfile, which participate the docker build.

But I accidentally deleted the tmp folder, even after I recovered it, it still throws the following error. What happened was that Prefect expected a tmp folder with a new random_number as the suffix. How can I recover from it?

Step 10/11 : COPY ./tmpnu2k398p/healthcheck.py /opt/prefect/healthcheck.py
COPY failed: stat /var/lib/docker/tmp/docker-builder531146691/tmpnu2k398p/healthcheck.py: no such file or directory
Error loading 'prefect_register_flow.py':
  Traceback (most recent call last):
    File "/Users/zhengxie1/workspace/cog_ana_model_train/venv/lib/python3.7/site-packages/prefect/cli/build_register.py", line 134, in load_flows_from_script
    namespace = runpy.run_path(abs_path, run_name="<flow>")
    File "/Users/zhengxie1/.pyenv/versions/3.7.3/lib/python3.7/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
    File "/Users/zhengxie1/.pyenv/versions/3.7.3/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
    File "/Users/zhengxie1/.pyenv/versions/3.7.3/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
    File "/Users/zhengxie1/workspace/cog_ana_model_train/prefect_register_flow.py", line 77, in <module>
    flow.storage.build()
    File "/Users/zhengxie1/workspace/cog_ana_model_train/venv/lib/python3.7/site-packages/prefect/storage/docker.py", line 303, in build
    self._build_image(push=push)
    File "/Users/zhengxie1/workspace/cog_ana_model_train/venv/lib/python3.7/site-packages/prefect/storage/docker.py", line 370, in _build_image
    "Your docker image failed to build!  Your flow might have "
  ValueError: Your docker image failed to build!  Your flow might have failed one of its deployment health checks - please ensure that all necessary files and dependencies have been included.
Zheng Xie
  • 415
  • 3
  • 13

1 Answers1

1

As a quick fix, you could disable the health check:

from prefect.storage import Docker

Docker(ignore_healthchecks=True)

In general, it looks like you run the registration itself in a Docker container, and this is why the health checks are failing. The registration step is building an image and right now you are building Docker images from a Docker container rather than from a local process. You could in theory solve it with docker.sock, but there is a much easier way.

You can create a virtual environment for the registration process. Within that environment, you can register all flows at once using CLI rather than doing that with a custom code:

prefect register --project yourproject -p /path/to/flows/dir/

All flows in the dir directory, will then be registered one by one, and for each of them, Prefect will build its own Docker image.

Anna Geller
  • 1,653
  • 7
  • 10