เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

การจับคู่ input ด้วย zip

ทีมของคุณมี pipeline สำหรับอัปโหลดไฟล์ไปยังตำแหน่งที่เก็บข้อมูลบน cloud เพื่อนร่วมทีมใช้ zip() ร่วมกับ expand_kwargs() เพื่อจับคู่แต่ละไฟล์กับปลายทางบน cloud storage:

@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 จะสร้าง instance ของ upload ทั้งหมดกี่รายการ?

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

การสร้าง Data Pipeline ด้วย Airflow

ดูคอร์ส

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำจริง

เปลี่ยนทฤษฎีให้เป็นการลงมือทำด้วยแบบฝึกหัดเชิงโต้ตอบหนึ่งในของเรา

เริ่มแบบฝึกหัด