Repository: astronomer/astronomer-cosmos

Issue:
cosmos_callback_dag DAG executing for significant duration in Airflow 3 (roughly ~10-12 mins)
While working on PR #1646, I observed that the `cosmos_callback_dag` example DAG takes significant time in completing it's execution. All others DAGs run relatively fast, but this appears just to be hanging for a long time causing the overall integration tests duration to be [~23 mins](https://github.com/astronomer/astronomer-cosmos/actions/runs/14707226913/job/41270420094?pr=1646) on **Airflow 3** compared to [~10 mins](https://github.com/astronomer/astronomer-cosmos/actions/runs/14707226913/job/41270419771?pr=1646) on **Airflow 2**.

Investigate the reason for the delay when time allows and see if the issue is on Airflow side of things or something can be optimised on Cosmos end.

Hints from issue comments:

Solution patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c4acf2bc..ffb776ba 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -50,14 +50,14 @@ repos:
       - id: remove-tabs
         exclude: ^docs/make.bat$|^docs/Makefile$|^dev/dags/dbt/jaffle_shop/seeds/raw_orders.csv$
   - repo: https://github.com/asottile/pyupgrade
-    rev: v3.19.1
+    rev: v3.20.0
     hooks:
       - id: pyupgrade
         args:
           - --py37-plus
           - --keep-runtime-typing
   - repo: https://github.com/astral-sh/ruff-pre-commit
-    rev: v0.11.10
+    rev: v0.11.11
     hooks:
       - id: ruff
         args:
diff --git a/cosmos/io.py b/cosmos/io.py
index f065d8bf..e702c095 100644
--- a/cosmos/io.py
+++ b/cosmos/io.py
@@ -183,7 +183,7 @@ def _construct_dest_file_path(
         f"{context['dag'].dag_id}"
         f"/{context['run_id']}"
         f"/{context['task_instance'].task_id}"
-        f"/{context['task_instance']._try_number}"
+        f"/{context['task_instance'].try_number}"
     )
     rel_path = os.path.relpath(file_path, source_target_dir).lstrip("/")
 


Test patch:
diff --git a/tests/operators/test_local.py b/tests/operators/test_local.py
index 9ba03763..55ab1948 100644
--- a/tests/operators/test_local.py
+++ b/tests/operators/test_local.py
@@ -1763,7 +1763,7 @@ def test_construct_dest_file_path_with_run_id():
     context = {
         "dag": MagicMock(dag_id="test_dag"),
         "run_id": "test_run_id",
-        "task_instance": MagicMock(task_id="test_task", _try_number=1),
+        "task_instance": MagicMock(task_id="test_task", try_number=1),
     }
     result = _construct_dest_file_path(dest_target_dir, file_path, source_target_dir, source_subpath, context=context)
 
diff --git a/tests/test_io.py b/tests/test_io.py
index 816ead51..0e109e9a 100644
--- a/tests/test_io.py
+++ b/tests/test_io.py
@@ -23,7 +23,7 @@ def dummy_kwargs():
         "context": {
             "dag": MagicMock(dag_id="test_dag"),
             "run_id": "test_run_id",
-            "task_instance": MagicMock(task_id="test_task", _try_number=1),
+            "task_instance": MagicMock(task_id="test_task", try_number=1),
         },
         "bucket_name": "test_bucket",
         "container_name": "test_container",