pierrejeambrun commented on PR #68760:
URL: https://github.com/apache/airflow/pull/68760#issuecomment-4812112102
Dag sample code, containing 2 dags. (legacy and new way of specifying the
colors)
```python
"""
Manual test DAGs for PR #68760 — "Restore graph task and group coloring via
Chakra palette tokens".
Two Dags:
* ``legacy_ui_colors`` — sets ``ui_color`` / ``ui_fgcolor`` the Airflow 2.x
way (raw hex and bare
CSS color names). Expected: a parse-time ``UserWarning`` for **each**
non-token value (visible in
the Dag processor logs), and **no** coloring in the Graph view because
legacy values are ignored.
* ``themed_ui_colors`` — sets the same attributes to Chakra palette tokens
(``family.shade``, e.g.
``blue.500``). Expected: **no** warnings, and the Graph view paints the
node fill from ``ui_color``
and the task label from ``ui_fgcolor`` (legible in both light and dark
mode).
Note: the operator warnings fire when the custom operator *classes* are
defined (i.e. as soon as this
file is parsed), since the check is on the class ``ui_color`` /
``ui_fgcolor`` attribute for
user-authored (non ``airflow.*``) modules. The TaskGroup warnings fire when
the groups are
instantiated. So importing this file alone should already surface the four
legacy warnings.
"""
from __future__ import annotations
import pendulum
from airflow.sdk import DAG, BaseOperator, TaskGroup
class _NoopOperator(BaseOperator):
"""Minimal runnable operator so the nodes render in the Graph view."""
def execute(self, context):
return None
# --- Legacy color classes (Airflow 2.x style). Defining each one emits a
UserWarning per attribute.
class LegacyHexOperator(_NoopOperator):
ui_color = "#e8b7e4"
ui_fgcolor = "#000000"
class LegacyCssNameOperator(_NoopOperator):
ui_color = "cornflowerblue"
ui_fgcolor = "white"
# --- New color classes using Chakra palette tokens. No warning; rendered in
the graph.
class TokenBlueOperator(_NoopOperator):
ui_color = "blue.500"
ui_fgcolor = "red.600" # vivid on purpose so the label color is
unmistakable
class TokenTealOperator(_NoopOperator):
ui_color = "teal.300"
ui_fgcolor = "purple.700"
with DAG(
dag_id="legacy_ui_colors",
schedule=None,
start_date=pendulum.datetime(2024, 1, 1, tz="UTC"),
catchup=False,
tags=["pr-68760", "legacy-colors"],
doc_md=__doc__,
):
legacy_hex = LegacyHexOperator(task_id="legacy_hex")
legacy_css = LegacyCssNameOperator(task_id="legacy_css_name")
# TaskGroup colors set the 2.x way -> one UserWarning per attribute at
instantiation, ignored by the graph.
with TaskGroup(group_id="legacy_group", ui_color="#1f77b4",
ui_fgcolor="#ffffff") as legacy_group:
LegacyHexOperator(task_id="inside_legacy")
legacy_hex >> legacy_css >> legacy_group
with DAG(
dag_id="themed_ui_colors",
schedule=None,
start_date=pendulum.datetime(2024, 1, 1, tz="UTC"),
catchup=False,
tags=["pr-68760", "themed-colors"],
doc_md=__doc__,
):
token_blue = TokenBlueOperator(task_id="token_blue")
token_teal = TokenTealOperator(task_id="token_teal")
# Token-valued TaskGroup colors -> no warning, painted in the graph.
with TaskGroup(group_id="themed_group", ui_color="purple.600",
ui_fgcolor="green.600") as themed_group:
TokenBlueOperator(task_id="inside_themed")
token_blue >> token_teal >> themed_group
```
<img width="593" height="298" alt="Screenshot 2026-06-26 at 20 01 57"
src="https://github.com/user-attachments/assets/332c1cb2-fcb8-4068-9731-20afe9159cca"
/>
--
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]