ferruzzi commented on code in PR #51638:
URL: https://github.com/apache/airflow/pull/51638#discussion_r2143136539


##########
airflow-core/src/airflow/models/deadline.py:
##########
@@ -220,9 +220,12 @@ class DagRunQueuedAtDeadline(BaseDeadlineReference):
 
         required_kwargs = {"dag_id"}
 
-        def _evaluate_with(self, **kwargs: Any) -> datetime:
+        @provide_session
+        def _evaluate_with(self, session=NEW_SESSION, **kwargs: Any) -> 
datetime:
             from airflow.models import DagRun
 
+            session.flush()

Review Comment:
   Sure, sorry about that.    If I change the signature to
   
   ```
       @provide_session
       def _set_dagrun_queued_deadline(self, session: Session = NEW_SESSION):
   ```
   
   Then three tests start to fail:
   
   ```
   [2025-06-12T08:57:29.667-0700] {dagbag.py:585} INFO - Filling up the DagBag 
from /dev/null
   FAILED [  2%][2025-06-12T08:57:29.672-0700] {collection.py:82} INFO - 
Creating ORM DAG for test_clear_task_instances_for_backfill_finished_dagrun
   
   airflow-core/tests/unit/models/test_dagrun.py:159 
(TestDagRun.test_clear_task_instances_for_backfill_finished_dagrun[success])
   0 != 1
   
   Expected :1
   Actual   :0
   <Click to see difference>
   
   unit/models/test_dagrun.py:173: in 
test_clear_task_instances_for_backfill_finished_dagrun
       assert dr0.clear_number == 1
   E   assert 0 == 1
   E    +  where 0 = <DagRun 
test_clear_task_instances_for_backfill_finished_dagrun @ 2025-06-12 
15:57:29.668728+00:00: backfill__2025-06-12T15:57:29.668728+00:00, 
state:queued, queued_at: 2025-06-12 15:57:29.686536+00:00. run_type: 
backfill>.clear_number
   [2025-06-12T08:57:29.827-0700] {dagbag.py:585} INFO - Filling up the DagBag 
from /dev/null
   FAILED [  3%][2025-06-12T08:57:29.833-0700] {collection.py:82} INFO - 
Creating ORM DAG for test_clear_task_instances_for_backfill_finished_dagrun
   
   airflow-core/tests/unit/models/test_dagrun.py:159 
(TestDagRun.test_clear_task_instances_for_backfill_finished_dagrun[failed])
   0 != 1
   
   Expected :1
   Actual   :0
   <Click to see difference>
   
   unit/models/test_dagrun.py:173: in 
test_clear_task_instances_for_backfill_finished_dagrun
       assert dr0.clear_number == 1
   E   assert 0 == 1
   E    +  where 0 = <DagRun 
test_clear_task_instances_for_backfill_finished_dagrun @ 2025-06-12 
15:57:29.828525+00:00: backfill__2025-06-12T15:57:29.828525+00:00, 
state:queued, queued_at: 2025-06-12 15:57:29.853305+00:00. run_type: 
backfill>.clear_number
   ```
   
   and
   
   ```
   FAILED [ 40%]
   airflow-core/tests/unit/models/test_dagrun.py:1029 
(TestDagRun.test_next_dagruns_to_examine_only_unpaused[queued])
   [<DagRun test_dags @ 2016-01-01 00:00:00+00:00: 
scheduled__2016-01-01T00:00:00+00:00, state:queued, queued_at: 2025-06-12 
15:57:34.377862+00:00. run_type: scheduled>] != []
   
   Expected :[]
   Actual   :[<DagRun test_dags @ 2016-01-01 00:00:00+00:00: 
scheduled__2016-01-01T00:00:00+00:00, state:queued, queued_at: 2025-06-12 
15:57:34.377862+00:00. run_type: scheduled>]
   <Click to see difference>
   
   unit/models/test_dagrun.py:1077: in 
test_next_dagruns_to_examine_only_unpaused
       assert runs == []
   E   assert equals failed
   E      -[                                 +[]                              
   E      -  <DagRun test_dags @ 2016-01-0                                  
   E      -1 00:00:00+00:00: scheduled__20                                  
   E      -16-01-01T00:00:00+00:00, state:                                  
   E      -queued, queued_at: 2025-06-12 1                                  
   E      -5:57:34.377862+00:00. run_type:                                  
   E      - scheduled>,                                                     
   E      -]
   PASSED [ 41%]
   ```



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