You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/14 00:49:10 UTC

[GitHub] [airflow] houqp commented on a change in pull request #9170: [WIP] Read only endpoint for XCom #8134

houqp commented on a change in pull request #9170:
URL: https://github.com/apache/airflow/pull/9170#discussion_r439780964



##########
File path: airflow/api_connexion/endpoints/xcom_endpoint.py
##########
@@ -26,18 +32,35 @@ def delete_xcom_entry():
     raise NotImplementedError("Not implemented yet.")
 
 
-def get_xcom_entries():
+@provide_session
+def get_xcom_entries(dag_id, dag_run_id, task_id, session):
     """
     Get all XCom values
     """
-    raise NotImplementedError("Not implemented yet.")
+    query = session.query(XCom)
+    query = query.filter(and_(XCom.dag_id == dag_id,
+                              XCom.task_id == task_id))
+    query = query.join(DR, and_(XCom.dag_id == DR.dag_id, XCom.execution_date == DR.execution_date))
+    query = query.filter(DR.run_id == dag_run_id)
+    return xcom_collection_schema.dump(XComCollection(xcom_entries=query.all(), total_entries=query.count()))

Review comment:
       does `query.count()` issue another count query to the db? if so, we should call `len` on rows returned by `query.all()` instead.

##########
File path: airflow/api_connexion/endpoints/xcom_endpoint.py
##########
@@ -26,18 +32,35 @@ def delete_xcom_entry():
     raise NotImplementedError("Not implemented yet.")
 
 
-def get_xcom_entries():
+@provide_session
+def get_xcom_entries(dag_id, dag_run_id, task_id, session):

Review comment:
       can you add type annotation to all handler functions?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org