def push_data(context): value = "Hello, World!" context['task_instance'].xcom_push(key='greeting', value=value)
To demonstrate the retrieval, Mara showed Leo two ways to read the message. The "Hard Way" (using the XCom API) and the "Smart Way" (using Jinja templating). xcom in airflow
First, keep data small. Limit XCom usage to metadata, small configuration snippets, or unique identifiers. For large data transfers, use XCom to pass the path or URI of the data stored in an external system like Amazon S3, Google Cloud Storage, or a data warehouse. def push_data(context): value = "Hello, World
Months passed, and Leo became proficient. He wrote complex DAGs with dozens of tasks passing XComs back and forth. Then, Airflow 2.0 arrived. def push_data(context): value = "Hello
To use XCom effectively, data engineers should follow a few guiding principles.
def push_function(**context): context['ti'].xcom_push(key='user_id', value=123)