hussein-awala commented on code in PR #77198:
URL: https://github.com/apache/airflow/pull/77198#discussion_r4614871463
##########
providers/common/ai/src/airflow/providers/common/ai/plugins/hitl_review.py:
##########
@@ -135,20 +135,20 @@ def _read_xcom_by_prefix(
include_node_regions=False,
)
entity = read.column_descriptions[0]["entity"]
- query = read.with_only_columns(entity.key,
entity.value).where(entity.key.like(f"{prefix}%"))
+ query = read.where(entity.key.like(f"{prefix}%"))
else:
- query = select(XComModel.key, XComModel.value).where(
+ query = select(XComModel).where(
XComModel.dag_id == dag_id,
XComModel.run_id == run_id,
XComModel.task_id == task_id,
XComModel.map_index == map_index,
XComModel.key.like(f"{prefix}%"),
)
result: dict[int, Any] = {}
- for key, value in session.execute(query).all():
- suffix = key[len(prefix) :]
+ for row in session.scalars(query):
+ suffix = row.key[len(prefix) :]
if suffix.isdigit():
- result[int(suffix)] = value
+ result[int(suffix)] = XCom.deserialize_value(row)
Review Comment:
Made it a plain `def`, so FastAPI runs it in the threadpool like the
approve/reject endpoints, and slow backend reads no longer block the event
loop. `/health` stays `async` since it does no I/O.
##########
providers/common/ai/src/airflow/providers/common/ai/plugins/hitl_review.py:
##########
@@ -112,7 +112,7 @@ def _read_xcom(
row = session.scalars(read).first()
if row is None:
return None
- return row.value
+ return XCom.deserialize_value(row)
Review Comment:
Both readers now go through one helper that calls `XCom._load(row)` where
the Task SDK has it, the same dispatch `lazy_sequence` and the coordinator XCom
backend use. So a backend that implements only `load_value` resolves its
references here too. Versions without #74858 fall back to
`deserialize_value(row)`. The reference-backend tests now also run with a
`load_value`-only stub (skipped where `BaseXCom` has no `load_value`), and
those fail without the change.
--
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]