You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "mhenc (via GitHub)" <gi...@apache.org> on 2023/02/14 11:05:27 UTC

[GitHub] [airflow] mhenc commented on a diff in pull request #28900: Convert DagFileProcessor.execute_callbacks to Internal API

mhenc commented on code in PR #28900:
URL: https://github.com/apache/airflow/pull/28900#discussion_r1105634473


##########
airflow/models/taskinstance.py:
##########
@@ -787,6 +788,38 @@ def error(self, session: Session = NEW_SESSION) -> None:
         session.merge(self)
         session.commit()
 
+    @classmethod
+    @internal_api_call
+    @provide_session
+    def get_task_instance(
+        cls,
+        dag_id: str,
+        run_id: str,
+        task_id: str,
+        map_index: int,
+        select_columns: bool = False,
+        lock_for_update: bool = False,
+        session: Session = NEW_SESSION,
+    ) -> TaskInstance | None:
+        query = (
+            session.query(*TaskInstance.__table__.columns) if select_columns else session.query(TaskInstance)
+        )
+        query = query.filter_by(
+            dag_id=dag_id,
+            run_id=run_id,
+            task_id=task_id,
+            map_index=map_index,
+        )
+
+        if lock_for_update:

Review Comment:
   how does it behave in Internal API? 
   Does it release the rows when session is destroyed (I expect it) - so just after the results are returned
   
   We may need to think about the scenario when the row-locking is important for potential race conditions or consistency, but I see it's outside of this PR (as we don't use it)



-- 
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: commits-unsubscribe@airflow.apache.org

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