-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtask.py
More file actions
29 lines (20 loc) · 682 Bytes
/
task.py
File metadata and controls
29 lines (20 loc) · 682 Bytes
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
import os
import requests
import yaml
def client(method, endpoint, json):
token = os.environ['YAWN_TOKEN']
headers = {'Authorization': f'Token {token}'}
url = f'https://yawn.live/api/{endpoint}'
response = requests.request(method, url, json=json, headers=headers)
print(response.content)
response.raise_for_status()
return response
def create_workflow():
workflow = yaml.load(open('task.yaml').read())
return client('post', 'workflows/', workflow).json()['id']
def start_run(wkfl_id):
data = {'workflow_id': wkfl_id}
client('post', 'runs/', data)
if __name__ == '__main__':
wkfl_id = create_workflow()
start_run(wkfl_id)