Skip to content

Error when emitting Asset Metadata if value in extra is of type np.float64 #53474

@astro-anand

Description

@astro-anand

Apache Airflow version

3.0.3

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

No response

What happened?

In version 3.0.2 I was able to emit an asset with some values pulled from a dataframe in the extra field. These values were of type np.float64. In 3.0.3, the task failed on attempting to emit the asset extra.

What you think should happen instead?

The asset should be created with the relevant extra.

How to reproduce

import random
from airflow.sdk import dag, task, Asset, AssetAlias

ALIAS = AssetAlias("s3://alias-example")

TEST_ASSET = Asset("s3://my-bucket/data/file.csv")


@dag(tags=["asset_demo"])
def asset_demo():

    @task
    def get_file_ids():
        return [i for i in range(10)]

    @task(outlets=[TEST_ASSET])
    def add_assets_to_alias(i, outlet_events):
        """
        adds assets to alias
        """
        import numpy as np

        random_value = random.randint(1, 100)
        print(random_value, "is the random value for file_id:", i)
        outlet_events[TEST_ASSET].extra = {
            "file_id": i,
            "random_value": random_value,
            "float_value": np.float64(1.23412415),
        }

    add_assets_to_alias.expand(i=get_file_ids())

asset_demo()

Operating System

Linux

Versions of Apache Airflow Providers

N/A

Deployment

Astronomer

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions