blag commented on code in PR #25419: URL: https://github.com/apache/airflow/pull/25419#discussion_r949493545
########## airflow/datasets/manager.py: ########## @@ -0,0 +1,62 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from sqlalchemy.orm.session import Session + +from airflow.utils.log.logging_mixin import LoggingMixin + + +class DatasetEventManager(LoggingMixin): + """ + A pluggable class that manages operations for dataset events. + + The intent is to have one place to handle all DatasetEvent-related operations, so different + Airflow deployments can use plugins that broadcast dataset events to each other. + """ + + def register_dataset_change(self, *, task_instance, dataset, extra=None, session: Session) -> None: + """ + For local datasets, look them up, record the dataset event, queue dagruns, and broadcast + the dataset event + """ + from airflow.datasets import Dataset + from airflow.models.dataset import DatasetEvent, DatasetModel + + if isinstance(dataset, Dataset): Review Comment: Well, I didn't want to change the [original behavior](https://github.com/apache/airflow/pull/25419/files#diff-62f7d8a52fefdb8e05d4f040c6d3459b4a56fe46976c24f68843dbaeb5a98487L1537). I _think_ the only other reasonable thing that somebody would pass in as the `dataset` parameter is a DatasetModel object, in which case we can (presumably) skip pulling it from the database. I've added a test for that case. -- 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]
