Dylan Lim
02/06/2023, 3:51 AMimport_paths
in Orion like how you would do so in Prefect 1.0?
My flows need to import functions from another folder in my source code and it’s unable to find it when I run the agent.Walter Cavinaw
02/06/2023, 3:55 AMDylan Lim
02/06/2023, 4:02 AMWalter Cavinaw
02/06/2023, 4:08 AMDylan Lim
02/07/2023, 3:29 AMimport os
from prefect import flow, get_run_logger
@flow
def log_location():
logger = get_run_logger()
<http://logger.info|logger.info>(os.getcwd())
if __name__ == '__main__':
log_location()
Deployed it on my machine and checked the .yaml file for the path and everything looked ok. Checked the logs and got this:
INFO: Downloading flow code from storage at '/home/dylan/prefect/flows'
INFO: /tmp/tmpiwcz1bmlprefect
The second line is the line produced by os.getcwd()
. I’m not sure why it’s downloading flow code from the path but executing it from tmp folder - how can I change that?
I think this is why my relative imports are failing… so for context I’m trying to import functions from a folder on the same level as ‘flows’. This is the bit of code in my flow code that fails:
import sys
sys.path.append("../")
from utilities.functions import get_sql_file
My file structure looks like this:
/prefect
/flows
test_log.py
/utilities
__init__.py
functions.py
Any help is appreciated!Walter Cavinaw
02/07/2023, 3:33 AMdeployment = Deployment.build_from_flow(
flow=flow_deployment['flow'],
name=flow_deployment['name'],
infrastructure=Process(working_dir="<censor>"),
storage=GitHub.load('<censor>'),
skip_upload=True,
path="<censor>",
work_queue_name='<censor>',
schedule=schedule,
apply=True,
parameters=parameters,
)
Dylan Lim
02/07/2023, 3:47 AM