forked from pytorch/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jobs.py
49 lines (40 loc) · 1.42 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
45
46
47
48
from __future__ import print_function
import sys, os, subprocess
import requests
import json
import argparse
from os import path
from os.path import join
import yaml
api_url = 'https://api.jarvice.com/jarvice'
script_dir = path.dirname(path.realpath(__file__))
def get_jobs(config):
username = config['username']
apikey = config['apikey']
res = requests.get('%s/jobs?username=%s&apikey=%s' % (api_url, username, apikey))
res = json.loads(res.content.decode('utf-8'))
jobs = []
for jobnumber, info in res.items():
# print(json.dumps(info, indent=2))
# print(jobnumber, info['job_api_submission']['nae']['name'])
# job_start_time": 1467578395
job = {}
job['number'] = jobnumber
job['image'] = info['job_api_submission']['nae']['name']
job['type'] = info['job_api_submission']['machine']['type']
job['count'] = int(info['job_api_submission']['machine']['nodes'])
job['status'] = info['job_status']
jobs.append(job)
return jobs
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--configfile', default=join(script_dir, 'nimbix.yaml'))
args = parser.parse_args()
config_path = args.configfile
if not config_path.startswith('/'):
config_path = join(script_dir, config_path)
with open(config_path, 'r') as f:
config = yaml.load(f)
for job in get_jobs(config):
print(job['type'], job['image'], job['count'], job['status'])
# print(get_jobs())