0

使用 docker 作为存储时,调用如下:

prefect register --project yourproject -p yourflow.py

似乎完美创建了一个tmp{randomNumber}文件夹并放置了 healthcheck.py 和一个 Dockerfile,它们参与了 docker 构建。

但是我不小心删除了tmp文件夹,即使我恢复了它,它仍然会抛出以下错误。发生的事情是 Prefect 期望一个tmp以新 random_number 作为后缀的文件夹。我怎样才能从中恢复?

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.
4

1 回答 1

1

作为快速修复,您可以禁用运行状况检查:

from prefect.storage import Docker

Docker(ignore_healthchecks=True)

一般来说,看起来你在 Docker 容器中运行注册本身,这就是健康检查失败的原因。注册步骤是构建映像,现在您正在从 Docker 容器而不是本地进程构建 Docker 映像。理论上你可以用docker.sock解决它,但是有一个更简单的方法。

您可以为注册过程创建一个虚拟环境。在该环境中,您可以使用 CLI 一次注册所有流,而不是使用自定义代码:

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

dir 目录中的所有流,然后将被一一注册,并且对于每个流,Prefect 将构建自己的 Docker 映像。

于 2021-12-02T11:09:01.947 回答