เฟรมเวิร์กสำหรับจัดตารางเวิร์กโฟลว์

Data Engineering เบื้องต้น

Vincent Vankrunkelsven

Data Engineer, DataCamp

ตัวอย่างไปป์ไลน์

 

ตัวอย่างไปป์ไลน์อย่างง่ายที่ดึงข้อมูลจาก csv ด้วย Spark

จะจัดตารางเวลาอย่างไร?

  • ด้วยตนเอง
  • เครื่องมือจัดตารางเวลา cron
  • แล้วความสัมพันธ์ระหว่างงานล่ะ?
Data Engineering เบื้องต้น

DAGs

Directed Acyclic Graph

  • ชุดของโหนด
  • เส้นเชื่อมแบบมีทิศทาง
  • ไม่มีวงจร

ตัวอย่าง DAG

Data Engineering เบื้องต้น

เครื่องมือสำหรับงานนี้

 

  • cron ของ Linux
  • Prefect และ Dagster
  • Apache Airflow
Data Engineering เบื้องต้น

โลโก้ของ Apache Airflow

  • สร้างขึ้นที่ Airbnb
  • DAGs
  • Python
Data Engineering เบื้องต้น

Airflow: ตัวอย่าง DAG

 

ตัวอย่าง DAG ของ Airflow

Data Engineering เบื้องต้น

Airflow: ตัวอย่างในโค้ด

@dag(dag_id="example_dag",
     start_date=datetime(2024, 1, 1),
     schedule="0 * * * *")
def example_dag():

@task def start_cluster(): ... @task def ingest_customer_data(): ... @task def ingest_product_data(): ... @task def enrich_customer_data(): ...
Data Engineering เบื้องต้น

Airflow: ตัวอย่างในโค้ด

@dag(dag_id="example_dag", ...)
def example_dag():
    ...
    # Set up dependency flow
    cluster = start_cluster()
    customers = ingest_customer_data()
    products = ingest_product_data()
    cluster >> [customers, products]
    [customers, products] >> enrich_customer_data()
# Run the DAG
example_dag()
Data Engineering เบื้องต้น

มาฝึกกันเถอะ!

Data Engineering เบื้องต้น

Preparing Video For Download...