使用 zip 配对输入
您的团队有一条将文件上传到特定云存储位置的流水线。同事使用 zip() 搭配 expand_kwargs(),将每个文件与其云存储目标一一配对:
@task
def get_files():
return ["users.csv", "orders.csv", "products.csv"]
@task
def get_destinations():
return ["s3://bronze/users/", "s3://bronze/orders/", "s3://bronze/products/"]
@task
def upload(file_to_upload):
# Simulate uploading a file to cloud storage
print(f"Uploading {file_to_upload[0]} to {file_to_upload[1]}")
files = get_files()
destinations = get_destinations()
upload.expand(file_to_upload=files.zip(destinations))
Airflow 将创建多少个 upload 实例?
本练习是课程的一部分
