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/07/18 03:52:18 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #24530: Filter on XCOM key name when calculating map lengths in MappedOperator

uranusjr commented on code in PR #24530:
URL: https://github.com/apache/airflow/pull/24530#discussion_r922955823


##########
tests/test_utils/mock_operators.py:
##########
@@ -161,3 +161,17 @@ def __init__(self, **kwargs):
 
     def execute(self, context: Context):
         pass
+
+
+class XCOMPushOperator(BaseOperator):
+    """
+    Operator which pushes an extra XCOM value along with the default XCOM_RETURN_KEY
+    """
+
+    def __init__(self, return_value, **kwargs):
+        super().__init__(do_xcom_push=True, **kwargs)
+        self.return_value = return_value
+
+    def execute(self, context: Context):
+        context['task_instance'].xcom_push(key='extra_key', value="extra_value")
+        return self.return_value

Review Comment:
   Since there’s only one test that needs this class, I’d put it in the test instead.



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