You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2025/04/16 12:44:45 UTC

(airflow) branch main updated: Make `DatasetOrTimeSchedule` compatible with Airflow 2.10.x (#49350)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new e80e41abe63 Make `DatasetOrTimeSchedule` compatible with Airflow 2.10.x (#49350)
e80e41abe63 is described below

commit e80e41abe63e7ff7ae17cc861b4d870c022207a7
Author: Kaxil Naik <ka...@apache.org>
AuthorDate: Wed Apr 16 18:14:38 2025 +0530

    Make `DatasetOrTimeSchedule` compatible with Airflow 2.10.x (#49350)
    
    Without it, it failed with the following error:
    
    ```
    Traceback (most recent call last):
      File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
      File "/files/dags/example_asset.py", line 183, in <module>
        schedule=DatasetOrTimeSchedule(
    TypeError: __init__() got an unexpected keyword argument 'datasets'
    ```
---
 airflow-core/src/airflow/timetables/__init__.py    | 11 ----------
 .../timetables/{__init__.py => datasets.py}        | 25 ++++++++++++----------
 2 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/airflow-core/src/airflow/timetables/__init__.py b/airflow-core/src/airflow/timetables/__init__.py
index f8ab95f0e99..9280166bf4e 100644
--- a/airflow-core/src/airflow/timetables/__init__.py
+++ b/airflow-core/src/airflow/timetables/__init__.py
@@ -17,14 +17,3 @@
 # under the License.
 # fmt: off
 """Timetables."""
-
-from __future__ import annotations
-
-from airflow.utils.deprecation_tools import add_deprecated_classes
-
-__deprecated_classes = {
-    "datasets": {
-        "DatasetOrTimeSchedule": "airflow.timetables.assets.AssetOrTimeSchedule",
-    },
-}
-add_deprecated_classes(__deprecated_classes, __name__)
diff --git a/airflow-core/src/airflow/timetables/__init__.py b/airflow-core/src/airflow/timetables/datasets.py
similarity index 60%
copy from airflow-core/src/airflow/timetables/__init__.py
copy to airflow-core/src/airflow/timetables/datasets.py
index f8ab95f0e99..b716435a5e0 100644
--- a/airflow-core/src/airflow/timetables/__init__.py
+++ b/airflow-core/src/airflow/timetables/datasets.py
@@ -1,4 +1,3 @@
-#
 # 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
@@ -15,16 +14,20 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-# fmt: off
-"""Timetables."""
-
 from __future__ import annotations
 
-from airflow.utils.deprecation_tools import add_deprecated_classes
+import warnings
+
+from airflow.timetables.assets import AssetOrTimeSchedule
+
+
+class DatasetOrTimeSchedule(AssetOrTimeSchedule):
+    """Deprecated alias for `AssetOrTimeSchedule`."""
 
-__deprecated_classes = {
-    "datasets": {
-        "DatasetOrTimeSchedule": "airflow.timetables.assets.AssetOrTimeSchedule",
-    },
-}
-add_deprecated_classes(__deprecated_classes, __name__)
+    def __init__(self, *, timetable, datasets) -> None:
+        warnings.warn(
+            "DatasetOrTimeSchedule is deprecated and will be removed in Airflow 3.2. Use `airflow.timetables.AssetOrTimeSchedule` instead.",
+            DeprecationWarning,
+            stacklevel=2,
+        )
+        super().__init__(timetable=timetable, assets=datasets)