From 846ae4606f3193a506d3b89f5e5888ee0c390b00 Mon Sep 17 00:00:00 2001 From: Amogh Desai Date: Thu, 8 May 2025 15:02:32 +0530 Subject: [PATCH 1/3] Adding backcompat shim for BaseNotifier --- .../src/airflow/notifications/basenotifier.py | 22 +++++++++++++++++++ task-sdk/src/airflow/sdk/__init__.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 airflow-core/src/airflow/notifications/basenotifier.py diff --git a/airflow-core/src/airflow/notifications/basenotifier.py b/airflow-core/src/airflow/notifications/basenotifier.py new file mode 100644 index 0000000000000..7310858754f4f --- /dev/null +++ b/airflow-core/src/airflow/notifications/basenotifier.py @@ -0,0 +1,22 @@ +# 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. + +"""Re exporting the new notifier module from Task SDK for backward compatibility.""" + +from __future__ import annotations + +from airflow.sdk.bases.notifier import BaseNotifier as BaseNotifier diff --git a/task-sdk/src/airflow/sdk/__init__.py b/task-sdk/src/airflow/sdk/__init__.py index 6e8491c3b7f76..d415333babb10 100644 --- a/task-sdk/src/airflow/sdk/__init__.py +++ b/task-sdk/src/airflow/sdk/__init__.py @@ -84,7 +84,7 @@ "AssetAll": ".definitions.asset", "AssetAny": ".definitions.asset", "AssetWatcher": ".definitions.asset", - "BaseNotifier": ".definitions.notifier", + "BaseNotifier": ".bases.notifier", "BaseOperator": ".bases.operator", "BaseOperatorLink": ".bases.operatorlink", "BaseSensorOperator": ".bases.sensor", From d57954764e6a5e5b6d2884476ba6437760bb5768 Mon Sep 17 00:00:00 2001 From: Amogh Desai Date: Thu, 8 May 2025 15:58:08 +0530 Subject: [PATCH 2/3] Adding deprecation warning too --- airflow-core/src/airflow/notifications/basenotifier.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/airflow-core/src/airflow/notifications/basenotifier.py b/airflow-core/src/airflow/notifications/basenotifier.py index 7310858754f4f..73e194e187754 100644 --- a/airflow-core/src/airflow/notifications/basenotifier.py +++ b/airflow-core/src/airflow/notifications/basenotifier.py @@ -20,3 +20,11 @@ from __future__ import annotations from airflow.sdk.bases.notifier import BaseNotifier as BaseNotifier +from airflow.utils.deprecation_tools import add_deprecated_classes + +__deprecated_classes = { + "base": { + "BaseNotifier": "airflow.sdk.bases.notifier.BaseNotifier", + }, +} +add_deprecated_classes(__deprecated_classes, __name__) From f9a644694dc23e2811fb84cda56abe4a31cf676b Mon Sep 17 00:00:00 2001 From: Amogh Desai Date: Fri, 9 May 2025 12:08:05 +0530 Subject: [PATCH 3/3] using deprecation properly --- .../airflow/notifications/{basenotifier.py => __init__.py} | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) rename airflow-core/src/airflow/notifications/{basenotifier.py => __init__.py} (86%) diff --git a/airflow-core/src/airflow/notifications/basenotifier.py b/airflow-core/src/airflow/notifications/__init__.py similarity index 86% rename from airflow-core/src/airflow/notifications/basenotifier.py rename to airflow-core/src/airflow/notifications/__init__.py index 73e194e187754..6a33cc53278ec 100644 --- a/airflow-core/src/airflow/notifications/basenotifier.py +++ b/airflow-core/src/airflow/notifications/__init__.py @@ -1,3 +1,4 @@ +# # 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 @@ -14,16 +15,14 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. - -"""Re exporting the new notifier module from Task SDK for backward compatibility.""" +"""Airflow Notifiers.""" from __future__ import annotations -from airflow.sdk.bases.notifier import BaseNotifier as BaseNotifier from airflow.utils.deprecation_tools import add_deprecated_classes __deprecated_classes = { - "base": { + "basenotifier": { "BaseNotifier": "airflow.sdk.bases.notifier.BaseNotifier", }, }