简体   繁体   中英

ModuleNotFoundError with one Prefect flow, but not the other

Cross-posting this question: 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 . I'm having a little difficulty getting the deployment right, after migrating from native code to dockerized code. I am using the latest version of Prefect v1 and need to solve this before I'm able to migrate to 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. 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

I answered directly on the GitHub issue. 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!

At this point, it is not clear to me if Prefect's docker integration or my numpy usage (declared in Poetry) are the problem.

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

It looks like your package aid is relative to / root file system

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 )

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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