-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Render DAG tags alphabetically #56478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Replace non-null assertion with proper null check and array destructuring - Add explicit error handling for missing mock data - Add Jest DOM types import for TypeScript compatibility - Maintains test functionality while following linting rules
|
I feel like we should add sorting to the API instead. |
|
Something like this can be added in the API side that should sort tags by name. diff --git a/airflow-core/src/airflow/api_fastapi/core_api/datamodels/dags.py b/airflow-core/src/airflow/api_fastapi/core_api/datamodels/dags.py
index 23aa4ec300..3ff50fd2b5 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/datamodels/dags.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/datamodels/dags.py
@@ -29,6 +29,7 @@ from pydantic import (
ConfigDict,
computed_field,
field_validator,
+ field_serializer
)
from airflow.api_fastapi.core_api.base import BaseModel, StrictBaseModel
@@ -114,6 +115,9 @@ class DAGResponse(BaseModel):
}
return serializer.dumps(payload)
+ @field_serializer('tags')
+ def serialize_tags(tags: list[DagTagResponse]):
+ return sorted(tags, key=lambda tag: tag.name) |
|
I aggree that this should be done at the API level. +1 for a field serializer. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
|
Closed in favour of #58883 as per recommendations |
The tags on the DAGs card view are rendered in the order they are received from the API server which can be inconsistent and makes it difficult to compare DAGs with the same tag-set. This sorts the labels first before rendering them.
A test has been added as well to confirm the functionality.