kacpermuda commented on code in PR #76982:
URL: https://github.com/apache/airflow/pull/76982#discussion_r4641912669
##########
airflow-core/src/airflow/dag_processing/collection.py:
##########
@@ -1471,12 +1474,22 @@ def add_asset_trigger_references(
for trigger in asset_watcher_triggers
}
triggers.update(trigger_hash_to_trigger_dict)
+ watcher_names[name_uri] = {
+ trigger_hash: trigger["watcher_name"]
+ for trigger_hash, trigger in
trigger_hash_to_trigger_dict.items()
+ }
trigger_hash_from_asset: set[int] =
set(trigger_hash_to_trigger_dict.keys())
asset_model = assets[name_uri]
- trigger_hash_from_asset_model: set[int] = {
- BaseEventTrigger.hash(trigger.classpath, trigger.kwargs) for
trigger in asset_model.triggers
- }
+ trigger_hash_from_asset_model: set[int] = set()
+ for watcher in asset_model.watchers:
+ trigger_hash =
BaseEventTrigger.hash(watcher.trigger.classpath, watcher.trigger.kwargs)
+ trigger_hash_from_asset_model.add(trigger_hash)
+ # Names are otherwise only written when a reference is
created, so a watcher renamed
+ # in the Dag file (or a wrong name stored by an older version)
would never be corrected.
+ watcher_name = watcher_names[name_uri].get(trigger_hash)
+ if watcher_name is not None and watcher.name != watcher_name:
+ watcher.name = watcher_name
Review Comment:
Added a warning and a test to make sure it's logged, thanks
--
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]