-
Notifications
You must be signed in to change notification settings - Fork 0
/
afd_dag.py
84 lines (58 loc) · 1.67 KB
/
afd_dag.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import sys
sys.path.append("/home/jmiller/git/AFDTools")
from datetime import datetime, timedelta
import airflow
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
args = dict(
{
"owner": "airflow",
"start_date": airflow.utils.dates.days_ago(1),
"email": ["[email protected]"],
"email_on_failure": False,
"retries": 1,
"retry_delay": timedelta(minutes=10),
}
)
dag = DAG(
dag_id="AFD_Workflow", schedule_interval="@hourly", default_args=args
)
###############################################################
def getForecast():
"""
"""
from forecast import Downloader
with open('data/offices.txt', 'r') as t:
OFFICES = t.readlines()
for office in OFFICES:
try:
d = Downloader(office.strip())
forecast = d.download()
d.insert(forecast)
except:
pass
grabForecast = PythonOperator(
task_id="grab_forecast", python_callable=getForecast, dag=dag
)
###############################################################
def getPhrases():
"""
"""
from extract import Extract
ex = Extract()
ex.run()
getPhrases = PythonOperator(
task_id="get_phrases", python_callable=getPhrases, dag=dag
)
###############################################################
def phrases2Dataset():
"""
"""
from dataset import Dataset
d = Dataset()
d.add2Dataset(total=1000)
add2Dataset = PythonOperator(
task_id="add_to_dataset", python_callable=phrases2Dataset, dag=dag
)
###############################################################
grabForecast >> getPhrases >> add2Dataset