Hi I have been successfully running a flow locally...
# prefect-community
s
Hi I have been successfully running a flow locally. I shut down the server in the evening and when I started working again in the morning  when I deployed the same flow I got  a 
Failed to load and execute Flow's environment: ModuleNotFoundError(
I followed the instruction seen in other slacks discussion on the error and restarted the Agent pointing to the path to my package p`refect agent local start --api http://172.19.0.6:4200 -p /home/simone/tmp_code/pysmFISH_auto -p /home/simone/tmp_code/pysmFISH_auto/pysmFISH --show-flow-logs`  This seems to solve the module error but the flow doesn’t run. Looking at the logs from the Agent is because 
ModuleNotFoundError: No module named 'numpy'
 , numpy is install in the env. If I restart the agent adding the path to the conda env I am using 
prefect agent local start --api <http://172.19.0.6:4200> -p /home/simone/tmp_code/pysmFISH_auto -p /home/simone/tmp_code/pysmFISH_auto/pysmFISH -p /home/simone/miniconda3/envs/prefect_dev  --show-flow-logs
  I get again the same initial error of missing module. I really cannot understand what is going on. Any help is really appreciated! thanks! Here is the flow I have been running Flow GIST ------UPDATE--------- It looks like that the agent cannot load the flow from the local directory. The local directory is there and contains the flow. The error persist even if I change the directory where to save the flows
n
Hi @simone - what happens when you remove the reference to
inner()
?
s
Hi, amazing catch! now things run fine only
Heartbeat failed to start
. Do you know what was the issue? naming of the function?
n
Nope! The issue here is that Prefect doesn't run your flows as scripts but instead as discreet units of work (your tasks). This means that global methods or variables that aren't added/decorated as tasks aren't guaranteed to be available to a given task. My suggestion would be to create your own serializable task that extends the Prefect Task class and add your method as a class method instead of a global one.
s
Ok I think i figure out the issue. The inner function was calling a
function_logger
that is a general function that create a
logger = prefect.utilities.logging.get_logger()
. If I call this function in
inner()
the system breaks but if I put directly
logger=prefect.utilities.logging.get_logger()
inside
inner()
everything works fine.
Ahh ok understood….I completely missed the point. I will convert my code as you suggested. Thanks a lot for the amazing help! BTW…I love the product and is making my life as a biologist processing large datasets amazingly easier! thanks for your time
👍 1
n
Glad to hear it! Let us know if you run into any other issues 🙂