Lee-W commented on code in PR #39912:
URL: https://github.com/apache/airflow/pull/39912#discussion_r1637445873
##########
airflow/models/dagrun.py:
##########
@@ -1538,11 +1539,28 @@ def schedule_tis(
and not ti.task.outlets
):
dummy_ti_ids.append((ti.task_id, ti.map_index))
- elif ti.task.start_from_trigger is True and
ti.task.start_trigger_args is not None:
- ti.start_date = timezone.utcnow()
- if ti.state != TaskInstanceState.UP_FOR_RESCHEDULE:
- ti.try_number += 1
- ti.defer_task(exception=None, session=session)
+ # check whether the operator supports start execution from
triggerer
+ elif ti.task.start_trigger_args is not None:
+ start_trigger_args = ti.task.start_trigger_args
+ if isinstance(ti.task, MappedOperator):
+ context = ti.get_template_context()
+ mapped_kwargs, _ = ti.task._expand_mapped_kwargs(context,
session)
+ start_from_trigger =
mapped_kwargs.get("start_from_trigger", ti.task.start_from_trigger)
+
+ # update the trigger_kwargs if it's in expanded kwargs
+ start_trigger_args.trigger_kwargs = mapped_kwargs.get(
+ "trigger_kwargs", start_trigger_args.trigger_kwargs
+ )
+ else:
+ start_from_trigger = ti.task.start_from_trigger
Review Comment:
But we'll need `context` and `session` to get the `mapped_kwargs` to set the
correct `start_from_trigger`. Is there a way to get `context` in
`MappedOperator`?
Regarding the `trigger_kwargs`, I think that's the main reason we want to
add this support to the mapped operator. Without expanding `trigger_kwargs`,
it'll be used just like standard mapped operator
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]