I'm experiencing a weird issue when I register my ...
# prefect-community
m
I'm experiencing a weird issue when I register my flows • I had only one flow with this dir structure ◦
extract_data.py
flow file (config for the flow) ▪︎ here I import the tasks directory with a simple
import tasks
tasks
at the same level, a directory with my tasks ◦ When I register this flow it works correctly in schedule basis • I just added a new flow
calculate_something.py
• The tasks for this flow are in the
tasks
directory too • now when I want to run this new flow I get
FlowStorageError('An error occurred while unpickling the flow:\n ModuleNotFoundError("No module named \'tasks\'")
What I don't get is... Why is it working for the first flow and not for this new one? Any ideas? I appreciate it
k
Are you using a local agent? This setup sounds like it should work. Are they using the same agent?
a
You could start your agent from a specific project directory to help Prefect find your extra modules such as your tasks module:
Copy code
prefect agent local start -p /Users/you/Desktop/prefect/tasks/
Check out this thread for more information on that error - to help you in your use case, I added an extra section for you! 🙂 https://discourse.prefect.io/t/when-i-run-my-flow-i-see-an-error-failed-to-load-and-exe[…]derror-no-module-named-users-username-what-is-happening/33
m
• yes it is local agent • now it is working, pointing to the source code folder as Anna suggested • But what I cannot understand is why the other flow was working with no issues ?
thank you for your valuable answers
hello, any ideas ?
k
I don’t have any idea without digging further because it looks good from what you described. As long as the agent is started from the same directory where those imports, then it should be fine. But this won’t work for multiple Flows that belong to different folders of course so at that point, you should specify a working directory:
Copy code
flow.run_config = LocalRun(working_dir="/path/to/working-directory")
But that setup looks good. Maybe what you can do is start a python interpreter in that directory and see if the imports work? The
calculate_something
is in the same directory as
extract_data
right?