|
|
|
|
Airflow Xcom Exclusive |verified| ❲Edge Safe❳Here you can generate download CW practice files in the MP3 format. Those can for example be used on a portable MP3 player, or where ever using LCWO is not possible. Along with the files, you can also download the texts, to check your results. Select the number of files, their speed, duration and content below. Airflow Xcom Exclusive |verified| ❲Edge Safe❳def push_exclusive(ti): ti.xcom_push(key=f"run_ti.execution_date_data", value="sensitive") If you do not want to set up a Custom XCom Backend, you can use the "Cloud Path" strategy. Task A uploads a file to S3 and returns the file path string. Task B pulls the file path string via XCom and opens the file directly from S3. Best Practices for Using XCom At its foundational level, an XCom is a key-value pair explicitly designed to pass small amounts of metadata between tasks within the same Directed Acyclic Graph (DAG) run. Push and Pull Dynamics XCom communication operates on a push-and-pull model: XComs are a mechanism for between tasks. airflow xcom exclusive Think of an XCom as a small note that one task writes down and another task reads later. By default, Airflow saves these notes in its metadata database. Key Terms to Know : Sending data from a task to the database. Pull : Fetching data from the database into a task. Key : The specific name or label given to the shared data. How XCom Works by Default If a Python function task ends with a return statement used purely for local debugging, Airflow will still push it to the database. If the return value is unnecessary, remove the return statement or explicitly set do_xcom_push=False in your operator configurations. If using SqlXComBackend with PostgreSQL, you can use SELECT ... FOR UPDATE to lock an XCom row during push/pull, but Airflow does not do this automatically. def push_exclusive(ti): ti xcom_backend = airflow.providers.redis.xcom.RedisXCom : When pulling data, always declare the exact task_ids you are pulling from to avoid bugs. Because standard XComs save data directly to your Airflow metadata database (like PostgreSQL or MySQL), large files will slow down your system. Passing huge CSV files, large dataframes, or images via standard XCom can crash your database and stop your entire data pipeline. Best Practices for Using XCom At its foundational def load_data(**kwargs): ti = kwargs['ti'] Here is an enterprise-grade example of a custom XCom backend using Amazon S3 and pickle serialization (you can substitute pickle with parquet or json depending on security requirements): |