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


##########
airflow/api_internal/actions/dag.py:
##########
@@ -0,0 +1,42 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from sqlalchemy import exc
+from sqlalchemy.orm import Session
+
+from airflow.api_internal.internal_api_call import internal_api_call
+from airflow.exceptions import TaskNotFound
+from airflow.models import Operator
+from airflow.utils.session import NEW_SESSION, provide_session
+
+
+class InternalApiDagActions:
+    @staticmethod
+    @internal_api_call
+    @provide_session
+    def get_serialized_dag(dag_id: str, task_id: str, session: Session = 
NEW_SESSION) -> Operator | None:

Review Comment:
   Can't we put this method in 
   https://github.com/apache/airflow/blob/main/airflow/models/serialized_dag.py
   or reuse any existing?
   
   Same comment for others.



##########
airflow/dag_processing/processor.py:
##########
@@ -689,19 +691,18 @@ def _execute_task_callbacks(self, dagbag: DagBag | None, 
request: TaskCallbackRe
             return
 
         simple_ti = request.simple_task_instance
-        ti: TI | None = (
-            session.query(TI)
-            .filter_by(
-                dag_id=simple_ti.dag_id,
-                run_id=simple_ti.run_id,
-                task_id=simple_ti.task_id,
-                map_index=simple_ti.map_index,
-            )
-            .one_or_none()
+        ti = InternalApiTaskInstanceActions.get_task_instance(

Review Comment:
   Alternativele you can `get_task_instance` method in this file (with 
`@internal_ap_call` decorator) so the whole logic is in a single place.



-- 
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-unsubscr...@airflow.apache.org

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

Reply via email to