Skip to content

Commit

Permalink
add my first dag
Browse files Browse the repository at this point in the history
  • Loading branch information
cmotte4git committed Jun 11, 2024
1 parent 673e9c4 commit 9ae2d23
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
Binary file added airflow/dags/__pycache__/my_dag.cpython-312.pyc
Binary file not shown.
56 changes: 56 additions & 0 deletions airflow/dags/my_dag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from airflow import DAG
from airflow.operators.python import PythonOperator, BranchPythonOperator
from airflow.operators.bash import BashOperator
from datetime import datetime
from random import randint


def _choose_best_model(ti):
accuracies = ti.xcom_pull(task_ids=[
'training_model_A',
'training_model_B',
'training_model_C'
])
best_accuracy = max(accuracies)
if (best_accuracy > 8):
return 'accurate'
return 'inaccurate'

def _training_model():
return randint(1, 10)

with DAG("my_dag", start_date=datetime(2024, 1, 1),
schedule_interval="@daily", catchup=False) as dag:

training_model_A = PythonOperator(
task_id="training_model_A",
python_callable=_training_model
)

training_model_B = PythonOperator(
task_id="training_model_B",
python_callable=_training_model
)

training_model_C = PythonOperator(
task_id="training_model_C",
python_callable=_training_model
)

choose_best_model = BranchPythonOperator(
task_id="choose_best_model",
python_callable=_choose_best_model
)

accurate = BashOperator(
task_id="accurate",
bash_command="echo 'accurate'"
)

inaccurate = BashOperator(
task_id="inaccurate",
bash_command="echo 'inaccurate'"
)


[training_model_A, training_model_B, training_model_C] >> choose_best_model >> [accurate, inaccurate]
2 changes: 1 addition & 1 deletion airflow/logs/scheduler/latest

0 comments on commit 9ae2d23

Please sign in to comment.