You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/01/04 12:36:07 UTC
[GitHub] [airflow] uranusjr commented on a change in pull request #19965: Map and Partial DAG authoring interface for Dynamic Task Mapping
uranusjr commented on a change in pull request #19965:
URL: https://github.com/apache/airflow/pull/19965#discussion_r778048361
##########
File path: airflow/decorators/task_group.py
##########
@@ -90,20 +88,26 @@ def _make_task_group(self, **kwargs) -> MappedTaskGroup:
return tg
def partial(self, **kwargs) -> "MappedTaskGroupDecorator[R]":
+ if self.partial_kwargs:
+ raise RuntimeError("Already a partial task group")
self.partial_kwargs.update(kwargs)
return self
def map(self, **kwargs) -> R:
- self.mapped_kwargs.update(kwargs)
+ if self.mapped_kwargs:
+ raise RuntimeError("Already a mapped task group")
+ self.mapped_kwargs = kwargs
call_kwargs = self.partial_kwargs.copy()
- call_kwargs.update({k: object() for k in self.mapped_kwargs})
+ duplicated_keys = set(call_kwargs).intersection(kwargs)
+ if duplicated_keys:
+ raise RuntimeError(f"Cannot map partial arguments: {', '.join(sorted(duplicated_keys))}")
+ call_kwargs.update({k: object() for k in kwargs})
- self._invoked = True
return super().__call__(**call_kwargs)
def __del__(self):
- if not self._invoked:
+ if not self.mapped_kwargs:
Review comment:
Maybe we should even disable `map()` and `partial()` without any arguments (because how’d they make sense…?) but let’s not bother.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org