Samuel Hinton
03/10/2021, 3:34 PMJim Crist-Harif
03/10/2021, 4:34 PMprefect.context . The following (untested) decorator might work:
import functools
from datetime import timedelta
import pendulum
from prefect.engine.signals import SKIP
def skip_if_late_by(timedelta):
def inner(func):
@functools.wraps(func):
def wrapped(*args, **kwargs):
if prefect.context["scheduled_start_time"] + timedelta > pendulum.now():
raise SKIP("Too late!")
return func(*args, **kwargs)
return wrapped
return inner
@task
@skip_if_late_by(timedelta(hours=10))
def my_task(a, b, c):
...
could raise FAIL instead to fail it (we should add an easy signal option for Cancelled too).Jim Crist-Harif
03/10/2021, 4:35 PMSamuel Hinton
03/10/2021, 5:02 PMJim Crist-Harif
03/10/2021, 6:28 PMSKIP will mark the task as skipped (and downstream tasks will usually also skip by default). Raising FAIL will mark the task as failed (and downstream tasks will usually not run since the upstream task didn't succeed).Braun Reyes
03/24/2021, 5:36 PM