Khung lập lịch workflow

Introduction to Data Engineering

Vincent Vankrunkelsven

Data Engineer, DataCamp

Một pipeline ví dụ

 

Ví dụ pipeline đơn giản trích xuất từ csv bằng Spark

Lên lịch thế nào?

  • Thủ công
  • Công cụ lập lịch cron
  • Còn phụ thuộc lẫn nhau thì sao?
Introduction to Data Engineering

DAG

Đồ thị có hướng không chu trình (DAG)

  • Tập các nút
  • Cạnh có hướng
  • Không có chu trình

Ví dụ DAG

Introduction to Data Engineering

Công cụ phù hợp công việc

 

  • cron trên Linux
  • Prefect và Dagster
  • Apache Airflow
Introduction to Data Engineering

Logo của Apache Airflow

  • Tạo tại Airbnb
  • Dùng DAG
  • Viết bằng Python
Introduction to Data Engineering

Airflow: ví dụ DAG

 

Ví dụ DAG trong Airflow

Introduction to Data Engineering

Airflow: ví dụ bằng mã

@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(): ...
Introduction to Data Engineering

Airflow: ví dụ bằng mã

@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()
Introduction to Data Engineering

Cùng luyện tập nào!

Introduction to Data Engineering

Preparing Video For Download...