ashb commented on a change in pull request #20286:
URL: https://github.com/apache/airflow/pull/20286#discussion_r781128089
##########
File path: airflow/models/taskinstance.py
##########
@@ -2128,6 +2135,28 @@ def set_duration(self) -> None:
self.duration = None
self.log.debug("Task Duration set to %s", self.duration)
+ @provide_session
+ def _record_task_map_for_downstreams(self, value: Any, *, session: Session
= NEW_SESSION) -> None:
+ if not self.task.has_mapped_dependants():
+ return
+ if not isinstance(value, collections.abc.Collection):
+ return # TODO: Error if the pushed value is not mappable?
+ session.query(TaskMap).filter_by(
+ dag_id=self.dag_id,
+ task_id=self.task_id,
+ run_id=self.run_id,
+ map_index=self.map_index,
+ ).delete()
+ instance = TaskMap(
+ dag_id=self.dag_id,
+ task_id=self.task_id,
+ run_id=self.run_id,
+ map_index=self.map_index,
+ length=len(value),
+ keys=(list(value) if isinstance(value, collections.abc.Mapping)
else None),
Review comment:
Maybe it makes sense to move this logic in to the ctor for `TaskMap`?
--
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]