Skip to content

Commit 90dd3b6

Browse files
committed
feat(ariflow): docker and dag set-up
1 parent 6264636 commit 90dd3b6

5 files changed

Lines changed: 42 additions & 4 deletions

File tree

.github/workflows/docker-airflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
pull_request:
99
paths:
1010
- 'pyproject.toml'
11-
- './docker/**'
11+
- 'tools/images/**'
1212
- '.github/workflows/**'
1313

1414
env:

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
.env
22
.DS_Store
33

4+
# Ignore any file anywhere in the repository called env_variables
5+
src/airflow/src/env_variables.json
6+
47
# Ignore all Airflow related configurations
58
**/airflow/config/
69
!.gitkeep
7-
**/airflow/dags/
8-
!.gitkeep
910
**/airflow/plugins/
1011
!.gitkeep
1112
**/airflow/logs/

src/airflow/dags/dag-inference.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from airflow import DAG
2+
from airflow.providers.docker.operators.docker import DockerOperator
3+
from datetime import datetime, timedelta
4+
5+
default_args = {
6+
'owner': 'airflow',
7+
'retries': 1,
8+
'retry_delay': timedelta(minutes=5),
9+
}
10+
11+
with DAG(
12+
dag_id='weekly_inference_dag',
13+
default_args=default_args,
14+
description='Trigger ML inference every week',
15+
schedule_interval='0 9 * * 1', # Every Monday at 9:00 AM
16+
start_date=datetime(2024, 1, 1),
17+
catchup=False,
18+
tags=['ml', 'neo4j', 'inference'],
19+
) as dag:
20+
21+
inference_task = DockerOperator(
22+
task_id='inference',
23+
image='ghcr.io/sdsc-ordes/open-pulse-airflow:latest',
24+
auto_remove=True,
25+
environment={
26+
'INFERENCE_URL': Variable.get("INFERENCE_URL"),
27+
'NEO4J_DATABASE': Variable.get("NEO4J_DATABASE"),
28+
'API_TOKEN': Variable.get("API_TOKEN"),
29+
},
30+
)
31+
32+
inference_task
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"NEO4J_DATABASE": "",
3+
"INFERENCE_URL": "",
4+
"API_TOKEN": ""
5+
}

src/airflow/src/inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
import os
44

5-
BASE_URL = os.getenv('ML_BASE_URL', 'https://your-api.com')
5+
BASE_URL = os.getenv('INFERENCE_URL')
66
NEO4J_DB = os.getenv('NEO4J_DATABASE')
77
API_TOKEN = os.getenv('API_TOKEN')
88

0 commit comments

Comments
 (0)