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 2020/11/12 17:32:26 UTC

[GitHub] [airflow] casassg commented on a change in pull request #12312: Check for TaskGroup in _PythonDecoratedOperator

casassg commented on a change in pull request #12312:
URL: https://github.com/apache/airflow/pull/12312#discussion_r522287577



##########
File path: airflow/operators/python.py
##########
@@ -190,7 +193,15 @@ def _get_unique_task_id(task_id: str, dag: Optional[DAG] = None) -> str:
           task_id__20
         """
         dag = dag or DagContext.get_current_dag()
-        if not dag or task_id not in dag.task_ids:
+        if not dag:
+            return task_id
+
+        # We need check if we are in context of TaskGroup as the task_id may
+        # already be altered
+        task_group = task_group or TaskGroupContext.get_current_task_group(dag)
+        tg_task_id = task_group.child_id(task_id) if task_group else None
+
+        if (task_id not in dag.task_ids) and (tg_task_id not in dag.task_ids):

Review comment:
       Oh damn, that makes sense!




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org