工作流程排程框架

Data Engineering 入門

Vincent Vankrunkelsven

Data Engineer, DataCamp

範例 pipeline

 

用 Spark 從 CSV 萃取的簡易 pipeline 範例

如何進行排程?

  • 手動
  • cron 排程工具
  • 相依關係怎麼辦?
Data Engineering 入門

DAG(有向無環圖)

有向無環圖

  • 節點集合
  • 有向邊
  • 無循環

DAG 範例

Data Engineering 入門

合用的工具

 

  • Linux 的 cron
  • Prefect 與 Dagster
  • Apache Airflow
Data Engineering 入門

Apache Airflow 標誌

  • 由 Airbnb 創建
  • 使用 DAGs
  • 以 Python 為主
Data Engineering 入門

Airflow:DAG 範例

 

Airflow DAG 範例

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...