Kerangka penjadwalan workflow

Pengantar Data Engineering

Vincent Vankrunkelsven

Data Engineer, DataCamp

Contoh pipeline

 

Contoh pipeline sederhana yang mengekstrak dari csv dengan Spark

Bagaimana menjadwalkan?

  • Secara manual
  • Alat penjadwalan cron
  • Bagaimana dengan dependensi?
Pengantar Data Engineering

DAG

Directed Acyclic Graph

  • Himpunan node
  • Sisi terarah
  • Tanpa siklus

Contoh DAG

Pengantar Data Engineering

Alat yang digunakan

 

  • cron di Linux
  • Prefect dan Dagster
  • Apache Airflow
Pengantar Data Engineering

Logo Apache Airflow

  • Dibuat di Airbnb
  • DAG
  • Python
Pengantar Data Engineering

Airflow: contoh DAG

 

Contoh DAG Airflow

Pengantar Data Engineering

Airflow: contoh dalam kode

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

Airflow: contoh dalam kode

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

Ayo berlatih!

Pengantar Data Engineering

Preparing Video For Download...