You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2023/08/28 07:09:34 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #33720: Optimise and migrate to SA2-compatible syntax for TaskReschedule

uranusjr commented on code in PR #33720:
URL: https://github.com/apache/airflow/pull/33720#discussion_r1306999984


##########
airflow/models/taskreschedule.py:
##########
@@ -142,9 +154,93 @@ def find_for_task_instance(
         :param try_number: Look for TaskReschedule of the given try_number. Default is None which
             looks for the same try_number of the given task_instance.
         """
-        return TaskReschedule.query_for_task_instance(
-            task_instance, session=session, try_number=try_number
-        ).all()
+        return session.scalars(cls.stmt_for_task_instance(task_instance, try_number=try_number)).all()
+
+    @classmethod
+    @provide_session
+    def find_last_for_task_instance(

Review Comment:
   I wonder if we really need this method at all. The logic is rather simple and does not really provide any encapsulation benefits. (Same for `find_for_task_instance` above but it’s already there so there’s probably an argument for keeping it.)



##########
airflow/models/taskreschedule.py:
##########
@@ -142,9 +154,93 @@ def find_for_task_instance(
         :param try_number: Look for TaskReschedule of the given try_number. Default is None which
             looks for the same try_number of the given task_instance.
         """
-        return TaskReschedule.query_for_task_instance(
-            task_instance, session=session, try_number=try_number
-        ).all()
+        return session.scalars(cls.stmt_for_task_instance(task_instance, try_number=try_number)).all()
+
+    @classmethod
+    @provide_session
+    def find_last_for_task_instance(

Review Comment:
   I wonder if we really need this method at all. The logic is rather simple and does not really provide any encapsulation benefits. (Same for `find_for_task_instance` above but it’s already there so there’s probably an argument for keeping 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