Table of Contents
TimeDeltaSensor¶
Use the TimeDeltaSensor
to end sensing after specific time.
t0 = TimeDeltaSensor(task_id="wait_some_seconds", delta=datetime.timedelta(seconds=2))
TimeDeltaSensorAsync¶
Use the TimeDeltaSensorAsync
to end sensing after specific time.
It is an async version of the operator and requires Triggerer to run.
t0a = TimeDeltaSensorAsync(task_id="wait_some_seconds_async", delta=datetime.timedelta(seconds=2))
TimeSensor¶
Use the TimeSensor
to end sensing after time specified.
t1 = TimeSensor(
task_id="fire_immediately", target_time=datetime.datetime.now(tz=datetime.timezone.utc).time()
)
t2 = TimeSensor(
task_id="timeout_after_second_date_in_the_future",
timeout=1,
soft_fail=True,
target_time=(datetime.datetime.now(tz=datetime.timezone.utc) + datetime.timedelta(hours=1)).time(),
)
TimeSensorAsync¶
Use the TimeSensorAsync
to end sensing after time specified.
It is an async version of the operator and requires Triggerer to run.
t1a = TimeSensorAsync(
task_id="fire_immediately_async", target_time=datetime.datetime.now(tz=datetime.timezone.utc).time()
)
t2a = TimeSensorAsync(
task_id="timeout_after_second_date_in_the_future_async",
timeout=1,
soft_fail=True,
target_time=(datetime.datetime.now(tz=datetime.timezone.utc) + datetime.timedelta(hours=1)).time(),
)
BranchDayOfWeekOperator¶
Use the BranchDayOfWeekOperator
to branch your workflow based on week day value.
empty_task_1 = EmptyOperator(task_id="branch_true")
empty_task_2 = EmptyOperator(task_id="branch_false")
empty_task_3 = EmptyOperator(task_id="branch_weekend")
empty_task_4 = EmptyOperator(task_id="branch_mid_week")
branch = BranchDayOfWeekOperator(
task_id="make_choice",
follow_task_ids_if_true="branch_true",
follow_task_ids_if_false="branch_false",
week_day="Monday",
)
branch_weekend = BranchDayOfWeekOperator(
task_id="make_weekend_choice",
follow_task_ids_if_true="branch_weekend",
follow_task_ids_if_false="branch_mid_week",
week_day={WeekDay.SATURDAY, WeekDay.SUNDAY},
)
# Run empty_task_1 if branch executes on Monday, empty_task_2 otherwise
branch >> [empty_task_1, empty_task_2]
# Run empty_task_3 if it's a weekend, empty_task_4 otherwise
empty_task_2 >> branch_weekend >> [empty_task_3, empty_task_4]
DayOfWeekSensor¶
Use the DayOfWeekSensor
to sense for day of week.
t11 = DayOfWeekSensor(
task_id="week_day_sensor_failing_on_timeout", timeout=3, soft_fail=True, week_day=WeekDay.MONDAY
)