Skip to content

airflow tasks test cli not seeing xcom result #25008

@vinny-santaiti

Description

@vinny-santaiti

Apache Airflow version

2.3.3 (latest released)

What happened

The airflow tasks test CLI doesn't seem to work for xcoms, it used to work in version 2.2.5. It works fine in the UI.
Example: airflow tasks test tutorial print_date 2015-06-01
kwargs['ti'].xcom_pull(task_ids='push_data')
https://airflow.apache.org/docs/apache-airflow/stable/tutorial.html#id2
When you push data in a task, then pull xcom data by task_ids in a downstream task, it doesnt work.

What you think should happen instead

The same cli cmd did work fine in airflow 2.2.5

How to reproduce

import pendulum

from airflow import DAG
from airflow.operators.python import PythonOperator


with DAG(
    'example_xcom',
    schedule_interval=None,
    start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
    catchup=False,
) as dag:

    def push_data(**kwargs):
        return 'data'

    def pull_data(**kwargs):
        return kwargs['ti'].xcom_pull(task_ids='push_data')

    push_task = PythonOperator(
        task_id='push_data',
        python_callable=push_data
    )
    pull_task = PythonOperator(
        task_id='pull_data',
        python_callable=pull_data
    )
    push_task >> pull_task
airflow tasks test example_xcom push_data 2022-06-01
[2022-07-12 20:22:53,288] {python.py:173} INFO - Done. Returned value was: data
airflow tasks test example_xcom pull_data 2022-06-01
[2022-07-12 20:23:05,402] {python.py:173} INFO - Done. Returned value was: None

Operating System

docker

Versions of Apache Airflow Providers

apache-airflow==2.3.3
apache-airflow-providers-amazon==4.0.0
apache-airflow-providers-celery==3.0.0
apache-airflow-providers-cncf-kubernetes==4.1.0
apache-airflow-providers-docker==3.0.0
apache-airflow-providers-elasticsearch==4.0.0
apache-airflow-providers-ftp==3.0.0
apache-airflow-providers-google==8.1.0
apache-airflow-providers-grpc==3.0.0
apache-airflow-providers-hashicorp==3.0.0
apache-airflow-providers-http==3.0.0
apache-airflow-providers-imap==3.0.0
apache-airflow-providers-microsoft-azure==4.0.0
apache-airflow-providers-mysql==3.0.0
apache-airflow-providers-odbc==3.0.0
apache-airflow-providers-postgres==5.0.0
apache-airflow-providers-redis==3.0.0
apache-airflow-providers-sendgrid==3.0.0
apache-airflow-providers-sftp==3.0.0
apache-airflow-providers-slack==5.0.0
apache-airflow-providers-sqlite==3.0.0
apache-airflow-providers-ssh==3.0.0

Deployment

Docker-Compose

Deployment details

apache/airflow:2.3.3-python3.8
https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html

Anything else

No response

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions