seanghaeli commented on code in PR #75521: URL: https://github.com/apache/airflow/pull/75521#discussion_r4734208892
########## airflow-core/docs/core-concepts/asset-state-store.rst: ########## @@ -168,9 +168,15 @@ Calling the synchronous ``get``/``set``/``delete``/``clear`` from inside an ``as Using ``asset_state_store`` inside a Watcher Trigger ----------------------------------------------------- -:class:`~airflow.triggers.base.BaseEventTrigger` subclasses (watcher triggers) can read and write asset state store directly from within ``run()``. The triggerer injects ``self.asset_state_store`` before ``run()`` is called, scoped to the asset the trigger is watching. It is not available during ``__init__`` or ``serialize()``, only access it from within ``run()``. +:class:`~airflow.triggers.base.BaseEventTrigger` subclasses (watcher triggers) can read and write asset state store directly from within ``run()``. The triggerer injects ``self.asset_state_store`` before ``run()`` is called, scoped to the asset or assets this trigger watches. It is not available during ``__init__`` or ``serialize()``, only access it from within ``run()``. -Unlike task-based access (where the asset is identified by an inlet or outlet declaration), the accessor in a watcher trigger is automatically bound to the watched asset, so no subscripting is needed. +Unlike task-based access (where the asset is identified by an inlet or outlet declaration), the accessor in a watcher trigger is automatically bound to the watched assets, so no subscripting is needed. + +Watchers on several assets that use the same trigger class and arguments share one trigger. The accessor then covers all of those assets: ``set`` and ``delete`` apply to every one of them, and ``get`` returns the value from the first asset (by name) that holds the key. ``clear`` still needs exactly one asset, because it would also remove keys that tasks wrote, so a shared trigger should ``delete`` its own keys instead. Tasks and other triggers can use the same assets, so include what the trigger watches in the key name. Review Comment: Yes, while assets share a trigger their copies are treated as one value: the trigger writes all of them and reads the first by name that has the key, as agreed in #75352. A task writing that key on one of them is the same collision as a task overwriting a single-asset trigger's key. The docs now say a task that does want to change a shared trigger's state should write every watched asset, and the trigger logs a warning when the copies differ, naming the key and the assets. Keeping trigger and task state apart is #77755. -- 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]
