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 2021/02/18 11:13:09 UTC

[GitHub] [airflow] turbaszek commented on a change in pull request #14269: Make airflow dags show display TaskGroup.

turbaszek commented on a change in pull request #14269:
URL: https://github.com/apache/airflow/pull/14269#discussion_r578331430



##########
File path: airflow/utils/dot_renderer.py
##########
@@ -42,6 +45,80 @@ def _refine_color(color: str):
     return color
 
 
+def _draw_nodes(node: TaskMixin, parent_graph: graphviz.Digraph, states_by_task_id: Dict[str, str]) -> None:
+    """Draw the node and its children on the given parent_graph recursively."""
+    if isinstance(node, BaseOperator):
+        # Draw task
+        if states_by_task_id:
+            state = states_by_task_id.get(node.task_id, State.NONE)
+            color = State.color_fg(state)
+            fill_color = State.color(state)
+        else:
+            color = node.ui_fgcolor
+            fill_color = node.ui_color
+
+        parent_graph.node(
+            node.task_id,
+            _attributes={
+                "label": node.label,
+                "shape": "rectangle",
+                "style": "filled,rounded",
+                "color": _refine_color(color),
+                "fillcolor": _refine_color(fill_color),
+            },
+        )

Review comment:
       How about introducing `_draw_task` and `_draw_task_group` to encapsulate the logic and split logic of `_draw_nodes` into smaller pieces? 




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