Mike Lev11/04/2021, 2:59 PM
how can I do the equivalent of
to the run config working dir currently flows are working without a backend but then when I start to run on my server I get a an error with
currently my structure is as such
MainProject/ |-coreLogicModule/ |-PrefectStack/ flows/ -need access to coreLogic runflows.py
Mike Lev11/04/2021, 3:10 PM
• to run this, you
into the MainProject dir and run:
• as long as this package is installed in the environment from which you start the agent, and from the environment from which you register your flows, this should work without modifying the path or even adding the path to the agent • here is an example folder structure and setup.py: https://github.com/anna-geller/packaging-prefect-flows here is an example setup.py that you could use:
pip install -e .
LMK if you have questions to this.
from setuptools import setup, find_packages with open('requirements.txt') as f: requirements = f.read().splitlines() setup( name="coreLogicModule", version='0.01', # version this as you like packages=find_packages(), install_requires=requirements )
sharing example dir structure in case the explanation wasn’t clear
MainProject/ |-coreLogicModule/ |-PrefectStack/ flows/ -need access to coreLogic runflows.py # can now use: from <http://coreLogicModule.xyz|coreLogicModule.xyz> import abc requirements.txt setup.py
this will not work because the import happens during “build” time when the flow is registered, but you want it to be deferred and happen during run time when the flow is executed. The way to do this would be to use a task to defer appending the path. For example:
import sys sys.path.append("../..") import thing_in_directory_above @task def abc(): return thing_in_directory_above() with Flow(...) as flow: abc()
and now the appending is done when the Flow is running.
@task def abc(): import sys sys.path.append("../..") import thing_in_directory_above return thing_in_directory_above() with Flow(...) as flow: abc()
Mike Lev11/04/2021, 5:12 PM