Skip to content

Commit

Permalink
feat(dataset): allow "airflow.dataset.metadata.Metadata" import for b…
Browse files Browse the repository at this point in the history
…ackward compat (apache#44413)
  • Loading branch information
Lee-W authored Dec 2, 2024
1 parent f38a1ed commit 3c1124e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
7 changes: 1 addition & 6 deletions airflow/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -38,8 +37,4 @@
stacklevel=2,
)


__all__ = [
"Dataset",
"DatasetAlias",
]
__all__ = ["Dataset", "DatasetAlias"]
33 changes: 33 additions & 0 deletions airflow/datasets/metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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 __future__ import annotations

import warnings

from airflow.sdk.definitions.asset.metadata import Metadata

# TODO: Remove this module in Airflow 3.2

warnings.warn(
"Import from the airflow.dataset module is deprecated and "
"will be removed in the Airflow 3.2. Please import it from 'airflow.sdk.definitions.asset.metadata'.",
DeprecationWarning,
stacklevel=2,
)

__all__ = ["Metadata"]
9 changes: 9 additions & 0 deletions tests/datasets/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@
"will be removed in the Airflow 3.2. Please import it from 'airflow.sdk.definitions.asset'."
),
),
(
"airflow.datasets.metadata",
"Metadata",
(
"Import from the airflow.dataset module is deprecated and "
"will be removed in the Airflow 3.2. Please import it from "
"'airflow.sdk.definitions.asset.metadata'."
),
),
),
)
def test_backward_compat_import_before_airflow_3_2(module_path, attr_name, warning_message):
Expand Down

0 comments on commit 3c1124e

Please sign in to comment.