forked from azkaban/azkaban
-
Notifications
You must be signed in to change notification settings - Fork 3
/
jobs.py
executable file
·49 lines (35 loc) · 1.33 KB
/
jobs.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
#!/usr/bin/python3
from azkaban import Job, Project
from azkaban.remote import Session
import os
from glob import glob
cwd = os.getcwd()
def list_files(PATH=cwd):
result = [y for x in os.walk(PATH) for y in glob(os.path.join(x[0], '*.*'))]
return result
PROJECT_NAME = 'test_project'
print('building...')
project = Project(PROJECT_NAME)
for f in list_files(cwd + '/common'):
project.add_file(f, f.replace(cwd, ''))
project.properties = {'retries': 1, 'retry.backoff':60000}
flows = []
for j in range(1,2):
project.add_job(str(j) + '_' + str(0), Job({'type': 'command', 'command': 'sleep 1'}))
for i in range(1,5):
project.add_job(str(j) + '_' + str(i), Job({'type': 'command', 'command': 'echo gg', 'dependencies':str(j) + '_' + str(i-1)}))
flows.append(str(j) + '_' + str(4))
path = cwd + '/result.zip'
project.build(path, overwrite=True)
print('build complete')
print('uploading...')
session = Session('http://admin:admin@localhost:8081')
session.upload_project(PROJECT_NAME, path)
print('upload complete')
print('scheduling...')
option = {'concurrent':'skip', 'on_failure':'continue',
'notify_early':True, 'emails': (['gg@gg.com'],[])}
for f in flows:
print('scheduling ' + f)
session.schedule_workflow(PROJECT_NAME, f, '01/01/2018', '0,0,AM,PDT', '5m', **option)
print('schedule complete')