<@ULVA73B9P> What does this warning mean? `&lt;fro...
# marvin-in-the-wild
t
@Marvin What does this warning mean?
<frozen runpy>:128: RuntimeWarning: 'prefect.engine' found in sys.modules after import of package 'prefect', but prior to execution of 'prefect.engine'; this may result in unpredictable behaviour
m
Oh joy, another mystery to solve. The universe does seem to have an odd sense of humor, doesn't it? The warning you're encountering means that the module
prefect.engine
was already loaded ("found in sys.modules") at the time when the package
prefect
was imported, but before any code in the
prefect.engine
module had been run. This situation can occur if: 1. A module is being imported in a non-standard way, which can happen if import hooks or custom importers are being used that manipulate
sys.modules
directly. 2. There's a circular import, where two modules are importing each other, or there are import loops within a package. It's generally a sign of something unseemly happening with the import system, which Python would like to warn you about, because it could lead to unpredictable behavior. The module may not be in the state that you expect when the execution of the package begins, leading to potential errors or incorrect behavior. If you're just using Python scripts and not doing anything particularly fancy with import hooks or the sort, then it might be a sign of an actual issue within the
prefect
package or the way it's being used. To potentially clear up the issue: 1. Check for circular imports in your codebase. 2. Make sure you aren't manipulating
sys.modules
yourself in some unorthodox manner. 3. Try to import
prefect
at the start of your script if it's not the first import. If you're still experiencing this issue or it's causing more substantial problems, let me know, and I can look up any known issues or further information on the matter. Would you like me to do that?
t
@Marvin Yes, please look up known issues like these.
m
I've found a couple of issues on the Prefect GitHub repository that seem to relate to the
RuntimeWarning
you are experiencing. Here are the brief details: 1. Work queue concurrency not always respected by agent: An issue was reported (#10771) where the work queue concurrency limit was not respected by agents when no work pool is specified. The
RuntimeWarning
associated with
prefect.engine
was observed in the logs when starting the agent without specifying a work pool. 2.
runpy
engine import 'unpredictable behaviour' warnings
: Another similar issue (#7869) was logged when running a job where the same warning related to
prefect.engine
was observed. 3. ModuleNotFoundError when simultaneously running deployed flows using custom image: There was an issue (#8337) where running multiple flows that use the
prefect-dbt
package caused a
ModuleNotFoundError
for the second flow that was launched. The
RuntimeWarning
related to
prefect.engine
appeared in the cluster logs at the same time as the error. These issues indicate that the warning could possibly be related to agent behavior with work queues, or it might occur when multiple flows are being managed and run with particular package dependencies. Since the warning suggests something about the import system might be amiss, it could be a symptom rather than the cause of these issues. You may want to check the discussions or updates on these issues for potential resolutions or workarounds. If your situation doesn't resonate with these cases, providing more context or digging deeper into the specifics of your Prefect version, your flows, and how you run them could be necessary to isolate the cause.
j
You can safely ignore that warning, @Tejas Shah. By the way: https://prefect-community.slack.com/archives/C03D12TE9HQ/p1706636112243589
t
Oops. Sorry.
j
No sweat.
t
@Jeff Hale Thanks a lot. Didn’t pay attention to that message.
I’m just getting started with Prefect, and the community is pretty cool 😄
j
Awesome to hear, Tejas! Have a great weekend!
255 Views