amoghrajesh commented on code in PR #67530:
URL: https://github.com/apache/airflow/pull/67530#discussion_r3308830477
##########
task-sdk/src/airflow/sdk/execution_time/context.py:
##########
@@ -548,12 +547,12 @@ def set(self, key: str, value: JsonValue, *, retention:
timedelta | None = None)
# 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
+ stored: JsonValue = value
backend = _get_worker_state_backend()
- stored = (
- backend.serialize_task_state_to_ref(value=value, key=key,
ti_id=str(self._ti_id))
- if backend
- else 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_task_state_to_ref(value=value, key=key,
ti_id=str(self._ti_id))
+ stored = {"__type": "ExternalState", "__var": ref}
Review Comment:
From previous comments, the key is already hoisted to
`_EXTERNAL_STATE_REF_KEY` and the envelope reduced to a single key, so the
multi-key typo risk is gone.
Adding `_wrap_external_ref` / `_unwrap_external_ref` helpers now.
--
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]