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 10:51:44 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #20870: Fix task ID deduplication in @task_group

uranusjr commented on a change in pull request #20870:
URL: https://github.com/apache/airflow/pull/20870#discussion_r784746579



##########
File path: airflow/decorators/base.py
##########
@@ -86,15 +89,18 @@ def get_unique_task_id(
 
     if tg_task_id not in dag.task_ids:
         return task_id
-    core = re.split(r'__\d+$', task_id)[0]
-    suffixes = sorted(
-        int(re.split(r'^.+__', task_id)[1])
-        for task_id in dag.task_ids
-        if re.match(rf'^{core}__\d+$', task_id)
-    )
-    if not suffixes:
-        return f'{core}__1'
-    return f'{core}__{suffixes[-1] + 1}'
+
+    def _find_id_suffixes(dag: DAG) -> Iterator[int]:
+        prefix = re.split(r"__\d+$", tg_task_id)[0]

Review comment:
       This is the main fix; the previous logic incorrectly used `task_id`. Everything else is just re-organising code to make variable names more straightforward for future maintenance.




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