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

[GitHub] [airflow] dimberman commented on a diff in pull request #29433: Add dataset update endpoint

dimberman commented on code in PR #29433:
URL: https://github.com/apache/airflow/pull/29433#discussion_r1104614103


##########
airflow/api_connexion/endpoints/dataset_endpoint.py:
##########
@@ -120,3 +128,29 @@ def get_dataset_events(
     return dataset_event_collection_schema.dump(
         DatasetEventCollection(dataset_events=events, total_entries=total_entries)
     )
+
+
+@security.requires_access([(permissions.ACTION_CAN_CREATE, permissions.RESOURCE_DATASET)])
+@provide_session
+def post_dataset_event(session: Session = NEW_SESSION) -> APIResponse:
+    """Create a dataset event"""

Review Comment:
   Can you please add a more detailed description of what this function is doing



##########
airflow/datasets/manager.py:
##########
@@ -55,23 +55,31 @@ def register_dataset_change(
         dataset_model = session.query(DatasetModel).filter(DatasetModel.uri == dataset.uri).one_or_none()
         if not dataset_model:
             self.log.warning("DatasetModel %s not found", dataset)
-            return
-        session.add(
-            DatasetEvent(
+            return None
+
+        if task_instance:
+            dataset_event = DatasetEvent(
                 dataset_id=dataset_model.id,
                 source_task_id=task_instance.task_id,
                 source_dag_id=task_instance.dag_id,
                 source_run_id=task_instance.run_id,
                 source_map_index=task_instance.map_index,
                 extra=extra,
             )
-        )
+        else:
+            dataset_event = DatasetEvent(
+                dataset_id=dataset_model.id,
+                extra=extra,
+            )
+        session.add(dataset_event)

Review Comment:
   Please add a comment here explaining why we would create a dataset without a task instance. I think that would make it easier for folks reading this code in the future.



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