yermalov-here commented on code in PR #34418:
URL: https://github.com/apache/airflow/pull/34418#discussion_r1365271703


##########
airflow/datasets/manager.py:
##########
@@ -44,6 +45,13 @@ class DatasetManager(LoggingMixin):
     def __init__(self, **kwargs):
         super().__init__(**kwargs)
 
+    def create_datasets(self, dataset_models: list[DatasetModel], session: 
Session) -> None:
+        """Create new datasets."""
+        for dataset_model in dataset_models:
+            session.add(dataset_model)
+            self.notify_dataset_created(dataset=Dataset(uri=dataset_model.uri, 
extra=dataset_model.extra))
+        session.flush()  # this is required to ensure each dataset has its PK 
loaded

Review Comment:
   Addressed in 
https://github.com/apache/airflow/pull/34418/commits/c471bde88ba025d098c541b35e38d880ce368776
   `on_dataset_created` hook is now called after the database is flushed.



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