【问题标题】:ModuleNotFoundError with one Prefect flow, but not the otherModuleNotFoundError 与一个 Prefect 流程,但不是另一个
【发布时间】:2022-09-27 22:58:31
【问题描述】:

交叉发布这个问题:https://github.com/PrefectHQ/prefect/discussions/6868

我有一个使用 Prefect v1.3.1 的最小项目,您可以在这里找到:https://github.com/b-long/aid。在从本机代码迁移到 dockerized 代码之后,我在正确部署时遇到了一点困难。我正在使用最新版本的 Prefect v1,需要先解决这个问题,然后才能迁移到 Prefect 2.x

我正在使用 Poetry,但我很确定这里有一个适用于 Hatch、Pipenv、Flit 或其他工具的模式。在注册中观察到问题,该问题在最后记录:

ModuleNotFoundError: No module named \'aid\'

The command \'/bin/sh -c python /opt/prefect/healthcheck.py \'[\"/opt/prefect/flows/basic-pandas-flow.prefect\"]\' \'(3, 10)\'\' returned a non-zero code: 1
Traceback (most recent call last):
...
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.

如果你是一个 Prefect Guru,我猜你可以通过阅读日志文件(参见上面链接的讨论)并查看我的 Dockerfile 来解决这个问题:https://github.com/b-long/aid/blob/main/Dockerfile.prefect

    标签: python docker prefect


    【解决方案1】:

    在这一点上,我不清楚 Prefect 的 docker 集成还是我的 numpy 用法(在 Poetry 中声明)是问题所在。

    这个问题没有目前有一个解决方案,我建议任何有兴趣的人关注 Github 上的对话:https://github.com/PrefectHQ/prefect/discussions/6868

    【讨论】:

      【解决方案2】:

      看起来您的包 aid/ 根文件系统相关

      COPY README.md aid/ /aid/
      

      我相信如果你让它相对于/aid dir(你的工作目录是/aid,所以init文件需要在/aid/aid/__init__.py中)它会起作用

      COPY README.md /aid/
      COPY aid/ /aid/aid
      

      因此,将工作目录设为 root / 或将您的代码 (__init__.py) 复制到 /aid/aid

      【讨论】:

        【解决方案3】:

        我直接在 GitHub 问题上回答。让我们继续讨论,以便更容易在一个地方跟踪所有内容。

        顺便说一句,关于 GitHub 问题的精彩文章,非常有帮助!

        【讨论】:

        • 虽然我真的很感激帮助,但我不想为这个答案支付赏金,因为它似乎没有得到解决。如果我们可以通过 GitHub 进行更多对话,我会很乐意将此答案标记为解决方案 :)
        猜你喜欢
        • 2016-05-12
        • 2015-10-17
        • 2012-03-14
        • 2011-04-12
        • 2015-12-10
        • 2015-12-21
        • 2021-07-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多