This is an automated email from the ASF dual-hosted git repository. kaxilnaik pushed a commit to branch v2-10-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit c50ec27ee72d0ea451dbb7ea0710edc4690f8bb4 Author: Wei Lee <[email protected]> AuthorDate: Tue Dec 10 19:21:58 2024 +0800 feat(datasets): Raise deprecation warning when accessing Metadata through str (#44791) --- airflow/datasets/metadata.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/airflow/datasets/metadata.py b/airflow/datasets/metadata.py index 43dff928736..a2caabf4f43 100644 --- a/airflow/datasets/metadata.py +++ b/airflow/datasets/metadata.py @@ -17,6 +17,7 @@ from __future__ import annotations +import warnings from typing import TYPE_CHECKING, Any import attrs @@ -38,9 +39,26 @@ class Metadata: def __init__( self, target: str | Dataset, extra: dict[str, Any], alias: DatasetAlias | str | None = None ) -> None: + if isinstance(target, str): + warnings.warn( + ( + "Accessing outlet_events using string is deprecated and will be removed in Airflow 3. " + "Please use the Dataset or DatasetAlias object (renamed as Asset and AssetAlias in Airflow 3) directly" + ), + DeprecationWarning, + stacklevel=2, + ) self.uri = extract_event_key(target) self.extra = extra if isinstance(alias, DatasetAlias): self.alias_name = alias.name else: + warnings.warn( + ( + "Emitting dataset events using string is deprecated and will be removed in Airflow 3. " + "Please use the Dataset object (renamed as Asset in Airflow 3) directly" + ), + DeprecationWarning, + stacklevel=2, + ) self.alias_name = alias
