-
Notifications
You must be signed in to change notification settings - Fork 1
/
submitter.py
66 lines (59 loc) · 1.67 KB
/
submitter.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
import os
import sys
import requests
import time
TARGET_OS_ENV = [
"NNI_PLATFORM",
"NNI_EXP_ID",
"NNI_SYS_DIR",
"NNI_TRIAL_JOB_ID",
"NNI_OUTPUT_DIR",
"NNI_TRIAL_SEQ_ID",
"MULTI_PHASE",
"TRIAL_CONCURRENCY",
"CUDA_VISIBLE_DEVICES",
]
AIPERF_MASTER_IP = os.environ['AIPERF_MASTER_IP']
AIPERF_MASTER_PORT = os.environ['AIPERF_MASTER_PORT']
URL="http://{}:{}/api/trial/create".format(AIPERF_MASTER_IP, AIPERF_MASTER_PORT)
if __name__ == "__main__":
print("reveive submitter!!!")
data = {
"cmd":"",
"env":{}
}
NNI_PLATFORM = os.environ.get('NNI_PLATFORM')
for k in os.environ:
if k in TARGET_OS_ENV:
print(k,":",os.environ.get(k))
data["env"][k] = os.environ.get(k)
# print("NNI_PLATFORM:{}".format(NNI_PLATFORM))
print()
#print(sys.argv)
cmd = " ".join(sys.argv[1:])
print("CMD:")
print(cmd)
data["cmd"] = cmd
headers = {'Content-Type': 'application/json;charset=UTF-8'}
res = requests.post(
URL,
headers = headers,
json=data
)
print(res.json()["success"])
while(True):
URL="http://{}:{}/api/trial/query?{}".format(AIPERF_MASTER_IP, AIPERF_MASTER_PORT, os.environ.get("NNI_TRIAL_JOB_ID"))
headers = {'Content-Type': 'application/json;charset=UTF-8'}
data={"trial":os.environ.get("NNI_TRIAL_JOB_ID")}
res = requests.post(
URL,
headers = headers,
json=data
)
if res.json()["status"]=="finish":
print("DONE!")
break
else :
print(res.json())
print("waiting...")
time.sleep(60)