使用 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 的實例?
本練習屬於課程
