简体   繁体   English

ModuleNotFoundError 有一个 Prefect 流程,但不是另一个

[英]ModuleNotFoundError with one Prefect flow, but not the other

Cross-posting this question: https://github.com/PrefectHQ/prefect/discussions/6868交叉发布这个问题: https://github.com/PrefectHQ/prefect/discussions/6868

I have a minimal project using Prefect v1.3.1, which you can find here: https://github.com/b-long/aid .我有一个使用 Prefect v1.3.1 的最小项目,您可以在这里找到它: https://github.com/b-long/aid I'm having a little difficulty getting the deployment right, after migrating from native code to dockerized code.从本机代码迁移到 dockerized 代码后,我在正确部署时遇到了一些困难。 I am using the latest version of Prefect v1 and need to solve this before I'm able to migrate to Prefect 2.x我正在使用最新版本的 Prefect v1,需要在迁移到 Prefect 2.x 之前解决这个问题

I'm using Poetry, but I'm pretty sure there's a pattern here that would apply to Hatch, Pipenv, Flit or other tooling.我正在使用 Poetry,但我很确定这里有一种模式适用于 Hatch、Pipenv、Flit 或其他工具。 The problem is observed in registration which logs this toward the end:在注册中观察到这个问题,最后记录了这个:

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.

If you're a Prefect Guru, I'm guessing you'll be able to solve this issue by reading the log file (see discussion linked above) and looking at my Dockerfile: https://github.com/b-long/aid/blob/main/Dockerfile.prefect如果您是 Prefect Guru,我猜您可以通过阅读日志文件(参见上面链接的讨论)并查看我的 Dockerfile 来解决这个问题: https://github.com/b-long/援助/blob/main/Dockerfile.prefect

I answered directly on the GitHub issue.我直接回答了 GitHub 问题。 Let's keep the discussion there to make it easier to follow everything in one place.让我们继续讨论,以便更容易在一个地方跟踪所有内容。

Btw, great writeup on the GitHub issue, very helpful!顺便说一句,关于 GitHub 问题的精彩文章,非常有帮助!

At this point, it is not clear to me if Prefect's docker integration or my numpy usage (declared in Poetry) are the problem.在这一点上,我不清楚 Prefect 的 docker 集成还是我的numpy用法(在诗歌中声明)是问题所在。

This question doesn't have a solution at the moment, and I recommend anyone interested follow the conversation on Github: https://github.com/PrefectHQ/prefect/discussions/6868这个问题目前没有解决方案,我建议任何有兴趣的人关注 Github 上的对话: https://github.com/PrefectHQ/prefect/discussions/6868

It looks like your package aid is relative to / root file system看起来你的 package aid是相对于/根文件系统的

COPY README.md aid/ /aid/

I believe it will work if you make it relative to /aid dir (your working dir is /aid and so init file need to be in /aid/aid/__init__.py )我相信如果你使它相对于/aid dir 它将起作用(你的工作目录是/aid ,所以初始化文件需要在/aid/aid/__init__.py

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM