sortega commented on code in PR #68568:
URL: https://github.com/apache/airflow/pull/68568#discussion_r3595350300
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -757,9 +756,13 @@ def __hash__(self):
@property
def stats_tags(self) -> dict[str, str]:
"""Returns task instance tags."""
- return prune_dict(
- {"dag_id": self.dag_id, "task_id": self.task_id, "team_name":
getattr(self, "_team_name", None)}
- )
+ # Reuse the dag run's tags (dag_id, run_type, dag tags) and add the
task-level ones.
+ # team_name is a transient attribute resolved per-object at scheduling
time, so it may be set
+ # on the TI even when the dag run has not seen it — carry the TI's own
value when present.
+ tags = {**self.dag_run.stats_tags, "task_id": self.task_id}
+ if team_name := getattr(self, "_team_name", None):
Review Comment:
I think it's an artifact of how the _team_name is managed in the two models.
They should have the same value but if we copy it from the dag, the tests will
read weirdly. Happy to do so to close this issue.
--
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]