https://prefect.io logo
#prefect-community
Title
# prefect-community
m

Matias Godoy

04/15/2020, 10:10 AM
My fist question: I'm creating a Flow for one of the pipelines, and my Python file is getting really big already. Is it possible to split the file and import, for example, tasks from another .py file?
s

shazard

04/15/2020, 10:13 AM
Yes, this is completely possible. Just import as you would import a function from another file. I have yet to see official good practices in this regard, but what I would do is develop tasks in their own files (possibly multiples files if you need to have a logical segmentation) and the flow in its own file.
m

Matias Godoy

04/15/2020, 10:15 AM
Great! I'm glad it's possible. Thanks!
Okay, I can confirm this works as expected 🙂
👍 1
One thing to have in mind; when you start an agent to process your flows, you have to specify where it should look for your imports using the
-p
flag.
From the agent's help:
Copy code
Import paths which will be provided to each Flow's runtime environment.
                                  Used for Flows which might import from scripts or local packages.
                                  Multiple values supported e.g. `-p /root/my_scripts -p /utilities`
      --show-flow-logs, -f        Display logging output from flows run by the agent (available for Local and Docker agents only)
or simply start the agent while you're in the same directory as your flow