Dominick Olivito
06/13/2023, 3:43 PMruntime.deployment
information when setting a Flow's run name?
here's an example:
from prefect import flow, runtime
import datetime
def get_flow_run_name():
date = datetime.datetime.now().isoformat()
return f"{runtime.deployment.name}-{date}"
@flow(log_prints=True, flow_run_name=get_flow_run_name)
def hi_named_flow(name: str):
print(f"Hi {name}")
when I try to deploy this with local Prefect server, agent, and storage, the flow run hangs here:
11:32:06.748 | INFO | Flow run 'warm-numbat' - Downloading flow code from storage at '/<some_path>/flows/test'
but if use runtime.flow_run.flow_name
instead of runtime.deployment.name
, it worksJenny
06/16/2023, 8:50 PMDominick Olivito
06/20/2023, 1:23 PM2.10.12
Jenny
06/21/2023, 5:03 PMfrom prefect import flow, runtime
import datetime
def get_flow_run_name():
date = datetime.datetime.now().isoformat()
return f"{runtime.deployment.name}-{date}"
@flow(log_prints=True, flow_run_name=get_flow_run_name())
def hi_named_flow(name: str):
print(f"Hi {name}")
Note that I'm calling the get_flow_run_name
function.Dominick Olivito
06/21/2023, 11:58 PM@flow(flow_run_name=get_flow_run_name)
# instead of
@flow(flow_run_name=get_flow_run_name())
https://docs.prefect.io/2.10.12/concepts/flows/#flow-settings
is it true that the former is evaluated at flow run time, while the latter is evaluated at deployment time?Jenny
06/22/2023, 5:51 AM