jedcunningham commented on code in PR #24908:
URL: https://github.com/apache/airflow/pull/24908#discussion_r917218718


##########
airflow/models/taskinstance.py:
##########
@@ -1513,10 +1513,10 @@ def _run_raw_task(
         if not test_mode:
             session.add(Log(self.state, self))
             session.merge(self)
-            self._create_dataset_dag_run_queue_records(session=session)
+            self._create_dataset_dag_run_queue_records(context=context, 
session=session)
             session.commit()
 
-    def _create_dataset_dag_run_queue_records(self, *, session):
+    def _create_dataset_dag_run_queue_records(self, *, context: Context = 
None, session: Session):

Review Comment:
   ```suggestion
       def _create_dataset_dag_run_queue_records(self, *, session: Session) -> 
None:
   ```
   
   Wait, `context` isn't even used? Oh, and we missed the return type.



##########
airflow/models/taskinstance.py:
##########
@@ -1513,10 +1513,10 @@ def _run_raw_task(
         if not test_mode:
             session.add(Log(self.state, self))
             session.merge(self)
-            self._create_dataset_dag_run_queue_records(session=session)
+            self._create_dataset_dag_run_queue_records(context=context, 
session=session)

Review Comment:
   ```suggestion
               self._create_dataset_dag_run_queue_records(session=session)
   ```



##########
tests/models/test_taskinstance.py:
##########
@@ -1499,10 +1499,25 @@ def test_outlet_datasets(self, create_task_instance):
         ti._run_raw_task()
         ti.refresh_from_db()
         assert ti.state == State.SUCCESS
+
+        # check that one queue record created for each dag that depends on 
dataset 1
         assert session.query(DatasetDagRunQueue.target_dag_id).filter(
             DatasetTaskRef.dag_id == dag1.dag_id, DatasetTaskRef.task_id == 
'upstream_task_1'
         ).all() == [('dag3',), ('dag4',), ('dag5',)]
 
+        # check that one event record created for dataset1 and this TI
+        assert session.query(Dataset.uri).join(DatasetEvent.dataset).filter(
+            DatasetEvent.source_task_instance == ti
+        ).one() == ('s3://dag1/output_1.txt',)
+
+        # check that no other dataset events recorded
+        assert (
+                session.query(Dataset.uri)
+                .join(DatasetEvent.dataset)
+                .filter(DatasetEvent.source_task_instance == ti)
+                .count()
+            ) == 1

Review Comment:
   ```suggestion
               session.query(Dataset.uri)
               .join(DatasetEvent.dataset)
               .filter(DatasetEvent.source_task_instance == ti)
               .count()
           ) == 1
   ```
   
   This fixes one of the failing static checks.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to