Andy Dienes
04/13/2023, 2:53 PMprefect.context.get_run_context().start_time
, but that seems a little dangerous if the run is late; I'd rather pull the scheduled time if possibleChris White
prefect.runtime
to access contextual information such as scheduled start time, so here's the pattern I recommend:
@flow
def my_flow(x: datetime = None):
if x is None:
x = prefect.runtime.flow_run.scheduled_start_time
Andy Dienes
04/13/2023, 4:08 PMctx = prefect.context.get_run_context()
ctx.flow_run.expected_start_time
but yours seems cleaner, thanksprefect.runtime.flow_run.scheduled_start_time
gives the actual time that the job was scheduled. I'm looking for more the "logical" time, so if my schedule is a * * * *
cron, then this time will always be exactly on the minute. is there a way to get this besides my earlier pattern?Chris White
Andy Dienes
04/13/2023, 6:39 PMChris White
Andy Dienes
04/13/2023, 9:03 PMprefect.cli.deployment.pause_schedule(prefect.runtime.deployment.name)
to pause the deployment associated with that flow run? I'm not sure how to call this correctly, but this had seemed to be the waymyflowname/{prefect.runtime.deployment.name}