Skip to content

Commit

Permalink
Add sample DAG to dev environment
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandenburgh committed May 29, 2024
1 parent aa28ec1 commit 8062dd5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
34 changes: 34 additions & 0 deletions dev/airflow_sample_dag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from datetime import datetime

from airflow import DAG
from airflow.decorators import task
from airflow.models import Param

with DAG(
dag_id="RD-WATCH-AIRFLOW-DEMO-DAG",
description="Test DAG",
params={
"region_id": Param(
default="BR_R002", type="string", pattern=r"^[A-Z]{2}_[RCST]\d{3}$"
),
"model_run_title": Param(default="test_run", type="string"),
},
start_date=datetime(2022, 3, 1),
catchup=False,
schedule_interval=None,
max_active_runs=1,
default_view="grid",
tags=["demo", "watch", "ta2", "rgd", "random"],
) as dag1:

@task
def print_region(**context):
region_id = context["params"]["region_id"]
print(f"region_id: {region_id}")

@task
def print_model_run_title(**context):
model_run_title = context["params"]["model_run_title"]
print(f"model_run_title: {model_run_title}")

print_region() >> print_model_run_title()
5 changes: 5 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ services:
dockerfile: airflow.Dockerfile
volumes:
- airflow-data:/opt/airflow
- type: bind
source: ${PWD}/dev/airflow_sample_dag.py
target: /opt/airflow/dags/airflow_sample_dag.py
environment:
AIRFLOW_HOME: "/opt/airflow/"
command: ["airflow", "standalone"]
ports:
- 8002:8080
Expand Down

0 comments on commit 8062dd5

Please sign in to comment.