Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise deprecation warning when accessing metadata through str #44791

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions airflow/datasets/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from __future__ import annotations

import warnings
from typing import TYPE_CHECKING, Any

import attrs
Expand All @@ -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,
)
Lee-W marked this conversation as resolved.
Show resolved Hide resolved
self.alias_name = alias