Skip to content

Isolate xcom API from using serde deserialize for UI display #58887

@amoghrajesh

Description

@amoghrajesh

Body

Core API for xcom get used serde deserialize: https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/api_fastapi/core_api/routes/public/xcom.py#L102-L116.

The api is called with deserialize(full=False) which only means stringification.

def deserialize(o: T | None, full=True, type_hint: Any = None) -> object:
    """
    Deserialize an object of primitive type and uses an allow list to determine if a class can be loaded.

    :param o: primitive to deserialize into an arbitrary object.
    :param full: if False it will return a stringified representation
                 of an object and will not load any classes

For example:
This is my task:

    @task
    def task_b():
        return V1Pod(
            metadata=V1ObjectMeta(name="example-pod"),
            spec=V1PodSpec(
                containers=[
                    V1Container(
                        name="example-container",
                        image="busybox",
                        command=["sleep", "3600"],
                    )
                ]
            ),
        )

API returns:

kubernetes.client.models.v1_pod.V1Pod@version=1(spec={'containers': [{'name': 'example-container', 'image': 'busybox', 'command': ['sleep', '3600']}]},metadata={'name': 'example-pod'})

Since this is the case, core airflow can do well enough with only stringification code in it without whole library.

Committer

  • I acknowledge that I am a maintainer/committer of the Apache Airflow project.

Metadata

Metadata

Assignees

Labels

area:corekind:metaHigh-level information important to the community

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions