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/14 11:10:22 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #20743: Serialize mapped tasks and task groups

kaxil commented on a change in pull request #20743:
URL: https://github.com/apache/airflow/pull/20743#discussion_r784758697



##########
File path: airflow/models/baseoperator.py
##########
@@ -1672,20 +1677,52 @@ def _validate_kwarg_names_for_mapping(cls: Type[BaseOperator], func_name: str, v
 class MappedOperator(DAGNode):
     """Object representing a mapped operator in a DAG"""
 
-    operator_class: Type[BaseOperator] = attr.ib(repr=lambda c: c.__name__)
+    @staticmethod
+    def _operator_class_repr(val):
+        # Can be a string if we are de-serialized
+        if isinstance(val, str):
+            return val.rsplit('.', 1)[-1]
+        return val.__name__
+
+    def __repr__(self) -> str:
+        return (
+            'MappedOperator(operator_class={self._operator_class_repr(self.operator_class)}, '
+            + 'task_id={self.task_id!r}, partial_kwargs={self.partial_kwargs!r}, '
+            + 'mapped_kwargs={self.mapped_kwargs!r}, dag={self.dag})'

Review comment:
       ```suggestion
               f'MappedOperator(operator_class={self._operator_class_repr(self.operator_class)}, '
               + f'task_id={self.task_id!r}, partial_kwargs={self.partial_kwargs!r}, '
               + f'mapped_kwargs={self.mapped_kwargs!r}, dag={self.dag})'
   ```




-- 
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