uranusjr commented on a change in pull request #21019:
URL: https://github.com/apache/airflow/pull/21019#discussion_r792298894
##########
File path: airflow/models/taskinstance.py
##########
@@ -486,7 +486,7 @@ def __init__(
self.test_mode = False
@staticmethod
- def insert_mapping(run_id: str, task: "BaseOperator") -> dict:
+ def insert_mapping(run_id: str, task: "BaseOperator", map_index: int = -1)
-> dict:
""":meta private:"""
Review comment:
I think we should not have a default `map_index` here. The function is
private so we don’t need to worry about backward compatibility, and not having
a default helps prevent subtle bugs accidentally calling this without passing
an appropriate `map_index`.
##########
File path: airflow/models/baseoperator.py
##########
@@ -1800,6 +1801,53 @@ def wait_for_downstream(self) -> bool:
def depends_on_past(self) -> bool:
return self.partial_kwargs.get("depends_on_past") or
self.wait_for_downstream
+ def expand_mapped_task(self, upstream_ti: "TaskInstance", session:
"Session" = NEW_SESSION) -> None:
+ """Create the mapped TaskInstances for mapped task."""
+ # TODO: support having multiuple mapped upstreams?
+ from airflow.models.taskmap import TaskMap
+ from airflow.settings import task_instance_mutation_hook
+
+ task_map_info: TaskMap = (
+ session.query(TaskMap)
+ .filter_by(
+ dag_id=upstream_ti.dag_id,
+ task_id=upstream_ti.task_id,
+ run_id=upstream_ti.run_id,
+ map_index=upstream_ti.map_index,
+ )
+ .one()
+ )
+
+ unmapped_ti: Optional[TaskInstance] =
upstream_ti.dag_run.get_task_instance(
+ self.task_id, map_index=-1, session=session
+ )
+
+ maps = range(task_map_info.length)
+
+ if unmapped_ti:
+ # The unmapped TaskInstance still exists -- this means we haven't
+ # tried to run it before.
+ unmapped_ti.map_index = 0
+ maps = range(1, task_map_info.length)
Review comment:
I pushed a change to mark the unmapped ti as SKIPPED in this case.
--
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]