Complete the code to push a small value to XCom in an Airflow task.
task_instance.xcom_push(key='my_key', value=[1])
Only small, simple data like strings or numbers should be pushed to XCom due to size limits.
Complete the code to pull a value from XCom in an Airflow task.
value = task_instance.xcom_pull(task_ids=[1], key='my_key')
You must specify the task ID that pushed the XCom value to pull it correctly.
Fix the error in the code that tries to push a large file content to XCom.
with open('large_file.txt', 'r') as f: content = f.read() task_instance.xcom_push(key='file_content', value=[1])
Large file content should not be pushed directly to XCom. Instead, push a small reference like file size or path.
Fill both blanks to store a large result outside XCom and push its path instead.
result_path = '/tmp/result.json' with open(result_path, 'w') as f: json.dump([1], f) task_instance.xcom_push(key='result_path', value=[2])
Save large data to a file and push the file path to XCom as a small reference.
Fill all three blanks to read a large result from a file path pulled from XCom.
result_path = task_instance.xcom_pull(task_ids=[1], key=[2]) with open(result_path, [3]) as f: result = json.load(f)
Pull the file path from XCom using the correct task ID and key, then open the file in read mode.