sortega commented on code in PR #68568:
URL: https://github.com/apache/airflow/pull/68568#discussion_r3603684154
##########
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:
In the spirit of unblocking this last issue in this pull request, I've added
a new commit,
[f8908a8](https://github.com/apache/airflow/pull/68568/commits/f8908a87a60a2527b8109854052fe61c2d767c37).
It solves the problem by using the team_name from `self.dag_run.stats_tags`
but it's also removing the loop that sets the `_team_name` ephemeral attribute,
which is now dead code.
This feels to me a bit like scope creep, so I can also remove that last
commit if we don't want to modify that other feature here.
--
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]