jcozar
01/03/2022, 7:57 AMprefecthq/prefect:0.15.11-python3.8
), but I am using python 3.9 to register the flow to prefect cloud. It fails because I am using different python versions. Could you please clarify me how it works? Thank you very much!Anna Geller
stored_as_script=True
in your Docker storage - here are 2 examples that show how to use this pattern
• build your own image and pass it to your run config, and then use other type of storage.jcozar
01/03/2022, 11:02 AMPrefect Idioms
section in the core documentation. store_as_script
would work for me, thanks!jcozar
01/03/2022, 5:25 PMstore_as_script=False
uses cloudpickle to serialize the flow, and therefore the agent just needs to do flow.run()
. However, if I use store_as_script=True
, what does the agent? from script import flow
and then flow.run()
?
In particular I am reading some environment variables at the beginning of the script that are used by the flow and the tasks. If I use store_as_script=False
the flow run works ok, so I suppose that the tasks are using the values for env vars declared during the flow registration process (serialized in the cloudpickle object). However, if I use store_as_script=True
, I suppose that the whole python file is executed and for each flow run the env vars are loaded from current agent environment. Is that right?
Thank you in advance!Anna Geller
jcozar
01/03/2022, 6:13 PMdotenv.load_dotenv()
to setup a specific environment from a .env file at the beginning of my flow.py file. If I build the flow and serialize it using cloudpickle, the tasks inside the flow have the correct values for declared env vars (global variables created outside the flow and tasks).
In the links you gave me I checked that if using store_as_script=False
, the flow is serialized and loaded when required by the agent reading the binary file. However, if store_as_script=True
, the flow is loaded using this function that executes the whole python file and search for a prefect.Flow
object. Therefore the environment variables are loaded in that moment, so I should place the .env file in the Docker image as well.
Thanks again!