amoghrajesh commented on code in PR #67530:
URL: https://github.com/apache/airflow/pull/67530#discussion_r3308903509
##########
task-sdk/src/airflow/sdk/execution_time/context.py:
##########
@@ -661,15 +661,13 @@ def set(self, key: str, value: JsonValue) -> None:
from airflow.sdk.execution_time.comms import SetAssetStateByName,
SetAssetStateByUri, ToSupervisor
from airflow.sdk.execution_time.task_runner import SUPERVISOR_COMMS
- # if custom backend is configured, store the value on the custom
backend, and return the reference
- # to the stored value to store in the DB
backend = _get_worker_state_backend()
asset_ref = self._name or self._uri or ""
- stored = (
- backend.serialize_asset_state_to_ref(value=value, key=key,
asset_ref=asset_ref)
- if backend
- else value
- )
+ stored: JsonValue = value
+ if backend is not None:
+ # decorate the value with a marker to indicate that it's stored
externally, and include the ref to the external storage
+ ref = backend.serialize_asset_state_to_ref(value=value, key=key,
asset_ref=asset_ref)
+ stored = {"__type": "ExternalState", "__var": ref}
Review Comment:
Docstring added to both `serialize_task_state_to_ref` and
`serialize_asset_state_to_ref` in BaseStateBackend explaining that the
framework wraps/unwraps the envelope automatically and implementers should
return only the raw ref string.
On the UI link — the UI reads values directly from the DB and renders them
as-is. With this change, external refs will display as
`{"__airflow_state_ref__": "..."}` rather than a bare path string, which is the
intended visual signal. I linked the UI PR in the PR desc and the intended
design is that envelope shape itself being visible in the value column to
indicate that its an external ref
--
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]