SameerMesiah97 commented on code in PR #69171:
URL: https://github.com/apache/airflow/pull/69171#discussion_r3502050279


##########
airflow-core/src/airflow/api_fastapi/core_api/services/ui/dependencies.py:
##########
@@ -135,6 +135,19 @@ def get_scheduling_dependencies(readable_dag_ids: set[str] 
| None = None) -> dic
                     target = dep.target if ":" in dep.target else 
f"dag:{dep.target}"
                     edge_tuples.add((source, target))
 
+    # Create missing ``dag:`` nodes which may have been skipped by the loop 
above.
+    # A DAG referenced only as a trigger target or a sensor source may have no
+    # scheduling dependencies of its own. Without this loop, these DAGs will 
not be
+    # materialised and will result in dangling edges.
+    for source, target in edge_tuples:
+        for endpoint in (source, target):
+            if endpoint.startswith("dag:") and endpoint not in nodes_dict:
+                nodes_dict[endpoint] = {
+                    "id": endpoint,
+                    "label": endpoint.removeprefix("dag:"),
+                    "type": "dag",
+                }

Review Comment:
   this adds another full pass over all generated edges to discover missing DAG 
nodes. Have you considered folding this into the existing traversal instead? It 
seems like we already have all the information while constructing 
`edge_tuples`, so I'm wondering if we can avoid the extra pass entirely.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to