Skip to content

Metadata object issues unwarranted deprecation warning #51194

@Dev-iL

Description

@Dev-iL

Apache Airflow version

2.11.0

If "Other Airflow 2 version" selected, which one?

No response

What happened?

Following the documentation on Attaching extra information to an emitting dataset event causes an incorrect warning to be emitted. (The warning is incorrect in the sense that it says the user did something they didn't actually do - which is pass a string as the last input.)

Code from the docs' example:

    # Note that 3rd input, `alias`, isn't specified so it defaults to None.
    yield Metadata(example_s3_dataset, {"row_count": len(df)})

Then, in airflow/datasets/metadata.py, the branch that generates the warning is followed:

        if isinstance(alias, DatasetAlias):
            self.alias_name = alias.name
        else:  # This catches both `str` and `None`
            warnings.warn(...

What you think should happen instead?

The warning shouldn't say that a string (dataset uri) was passed instead of a Dataset object. Possibly, no warning should be emitted at all.

How to reproduce

Run the example from the docs verbatim.

Operating System

Linux

Versions of Apache Airflow Providers

No response

Deployment

Virtualenv installation

Deployment details

No response

Anything else?

Workaround

Provide a DatasetAlias(None) as the 3rd input to Metadata.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions