Airflow Xcom Example High Quality | ORIGINAL ✓ |

from airflow.operators.python import PythonOperator def push_func(ti): ti.xcom_push(key='result', value='hello_xcom')

# Push context['ti'].xcom_push(key='user_id', value=123) user = context['ti'].xcom_pull(task_ids='task_a', key='user_id') airflow xcom example

with DAG('xcom_example', start_date=datetime(2024, 1, 1), schedule_interval=None) as dag: from airflow

def pull_func(ti): value = ti.xcom_pull(task_ids='push_task', key='result') print(value) value=123) user = context['ti'].xcom_pull(task_ids='task_a'

Go to Task Instance → XCom tab → See key-value pairs.

1/4 Ever needed to pass a value from one Airflow task to another? → Use (Cross-Communication). Think of it as a mini shared dictionary for your DAG run. 🧠

extract = PythonOperator( task_id='extract_order_task', python_callable=extract_order )