Joshua Greenhalgh
05/23/2022, 2:36 PMtry:
scheduled_start_time: DateTime = prefect.context.scheduled_start_time
except AttributeError:
raise Exception("No start/end time params and no schedule")
Kevin Kho
05/23/2022, 2:37 PMauto_scheduled
in the contextJoshua Greenhalgh
05/23/2022, 2:39 PM'run_on_schedule': True
(this is from a run kicked off from the UI) and 'scheduled_start_time': DateTime(2022, 5, 23, 15, 4, 13, 497479, tzinfo=Timezone('+00:00'))
which is when I kicked it off?Kevin Kho
05/23/2022, 3:15 PMJoshua Greenhalgh
05/23/2022, 3:36 PMclock = clocks.IntervalClock(
timedelta(minutes=5), parameter_defaults={"is_scheduled_param": True}
)
set the param to false by default
is_scheduled_param = Parameter(name="is_scheduled_param", default=False)
start_time_param = Parameter(name="start_time_param", default=None)
end_time_param = Parameter(name="end_time_param", default=None)
start_time, end_time = get_ingestion_period(
start_time_param, end_time_param, is_scheduled_param
)
pass that into a function that needs to know if its running on a schedule...messy - should really be a flag but cannot find it 😞Kevin Kho
05/23/2022, 3:42 PMJoshua Greenhalgh
05/23/2022, 4:13 PMKevin Kho
05/23/2022, 8:28 PMauto_scheduled
is in the GraphQL backend. Not in context. So you can query for it with something like:
query = """
query($id: uuid!) {
flow_run(where: {id: {_eq: $id} }) {
id
auto_scheduled
}
}
"""
client.graphql(query=query, variables=dict(id=prefect.context["flow_run_id"]))