YD
08/11/2021, 5:18 AMimport os
import sys
PATH = 'Module path'
sys,path.append(PATH)
from <my module> import <my func>
when doing a test function, without a Prefect flows, I can run it from the command line.
when running the same function from a flow, I can run it when using flow.run()
, but when registering it in the cloud Prefect and trying to run it, I get
Failed to load and execute Flow's environment: FlowStorageError('An error occurred while unpickling the flow:\n ModuleNotFoundError("No module named \'<my module>\'")\nThis may be due to a missing Python module in your current environment. Please ensure you have all required flow dependencies installed.')
I am running a local agent on my machine, prefect agent local start
I do not use Docker containers
any suggestions ?Kevin Kho
cloudpickle
works. You need to package your dependencies into a Docker container and use Docker Storage so that the agent can pull the container with the dependencies.
If you are using Local agent and LocalRun, there are two ways to do this. First, is you can start the agent in the directory where the imports will resolve correctly is so it has access to those files when it runs the flow. Second is that LocalRun
takes in a working_dir
where you can specify where the agent will run the flow from.