Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions airflow-core/src/airflow/models/dagrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -2004,18 +2004,23 @@ def schedule_tis(
and not task.inlets
):
empty_ti_ids.append(ti.id)
# check "start_trigger_args" to see whether the operator supports start execution from triggerer
# if so, we'll then check "start_from_trigger" to see whether this feature is turned on and defer
# this task.
# if not, we'll add this "ti" into "schedulable_ti_ids" and later execute it to run in the worker
elif task.start_trigger_args is not None:
if task.expand_start_from_trigger(context=ti.get_template_context()):
ti.start_date = timezone.utcnow()
if ti.state != TaskInstanceState.UP_FOR_RESCHEDULE:
ti.try_number += 1
ti.defer_task(exception=None, session=session)
else:
schedulable_ti_ids.append(ti.id)
# Check "start_trigger_args" to see whether the operator supports
# start execution from triggerer. If so, we'll check "start_from_trigger"
# to see whether this feature is turned on and defer this task.
# If not, we'll add this "ti" into "schedulable_ti_ids" and later
# execute it to run in the worker.
# TODO TaskSDK: This is disabled since we haven't figured out how
# to render start_from_trigger in the scheduler. If we need to
# render the value in a worker, it kind of defeats the purpose of
# this feature (which is to save a worker process if possible).
# elif task.start_trigger_args is not None:
# if task.expand_start_from_trigger(context=ti.get_template_context()):
# ti.start_date = timezone.utcnow()
# if ti.state != TaskInstanceState.UP_FOR_RESCHEDULE:
# ti.try_number += 1
# ti.defer_task(exception=None, session=session)
# else:
# schedulable_ti_ids.append(ti.id)
else:
schedulable_ti_ids.append(ti.id)

Expand Down
3 changes: 2 additions & 1 deletion airflow-core/tests/unit/models/test_dagrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,7 @@ def test_schedule_tis_map_index(dag_maker, session):
assert ti2.state == TaskInstanceState.SUCCESS


@pytest.mark.xfail(reason="We can't keep this behaviour with remote workers where scheduler can't reach xcom")
@pytest.mark.need_serialized_dag
def test_schedule_tis_start_trigger(dag_maker, session):
"""
Expand Down Expand Up @@ -2092,7 +2093,7 @@ def test_schedule_tis_empty_operator_try_number(dag_maker, session: Session):
assert empty_ti.try_number == 1


@pytest.mark.xfail(reason="We can't keep this bevaviour with remote workers where scheduler can't reach xcom")
@pytest.mark.xfail(reason="We can't keep this behaviour with remote workers where scheduler can't reach xcom")
def test_schedule_tis_start_trigger_through_expand(dag_maker, session):
"""
Test that an operator with start_trigger_args set can be directly deferred during scheduling.
Expand Down
Loading