Skip to content

Commit cc762c7

Browse files
authored
Report relevant worker info for vulkan worker (#99)
1 parent cee68e5 commit cc762c7

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

python/src/main/python/drivers/vkrun.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ def run_linux(vert, frag, json, skip_render):
7878
with open('STATUS', 'w') as f:
7979
f.write(status)
8080

81+
def dump_info_linux():
82+
cmd = 'vkworker --info'
83+
status = 'SUCCESS'
84+
try:
85+
subprocess.run(cmd, shell=True, timeout=TIMEOUT_RUN).check_returncode()
86+
except subprocess.TimeoutExpired as err:
87+
status = 'TIMEOUT'
88+
except subprocess.CalledProcessError as err:
89+
status = 'CRASH'
90+
91+
with open('STATUS', 'w') as f:
92+
f.write(status)
93+
8194
################################################################################
8295
# Android
8396

@@ -163,11 +176,24 @@ def run_android(vert, frag, json, skip_render):
163176
adb('shell am force-stop ' + ANDROID_APP)
164177

165178
# Grab image if present
166-
imagepath = ANDROID_SDCARD + '/image.png'
179+
imagepath = ANDROID_SDCARD + '/image_0.png'
167180
retcode = adb('shell test -f ' + imagepath).returncode
168181
if retcode == 0:
169182
adb('pull ' + imagepath)
170183

184+
def dump_info_android():
185+
infofile = ANDROID_SDCARD + '/worker_info.json'
186+
adb('shell rm -f ' + infofile)
187+
adb('shell am force-stop ' + ANDROID_APP)
188+
adb('shell am start -n ' + ANDROID_APP + '/android.app.NativeActivity -e gfz "\"--info\""')
189+
deadline = time.time() + 1
190+
while time.time() < deadline:
191+
retcode = adb('shell test -f ' + infofile).returncode
192+
if retcode == 0:
193+
adb('pull ' + infofile)
194+
time.sleep(0.1)
195+
adb('shell am force-stop ' + ANDROID_APP)
196+
171197
################################################################################
172198
# Main
173199

python/src/main/python/drivers/worker_vk.py

+19-11
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def doImageJob(args, imageJob):
106106
name = imageJob.name.replace('.frag','')
107107
fragFile = name + '.frag'
108108
jsonFile = name + '.json'
109-
png = 'image.png'
109+
png = 'image_0.png'
110110
log = 'vklog.txt'
111111

112112
res = tt.ImageJobResult()
@@ -191,7 +191,7 @@ def doImageJob(args, imageJob):
191191

192192
################################################################################
193193

194-
def get_service(server, args):
194+
def get_service(server, args, worker_info_json_string):
195195
try:
196196
httpClient = THttpClient.THttpClient(server)
197197
transport = TTransport.TBufferedTransport(httpClient)
@@ -200,14 +200,7 @@ def get_service(server, args):
200200
transport.open()
201201

202202
# Get token
203-
204-
# TODO: grab information from worker
205-
206-
platforminfo = '''
207-
{
208-
"clientplatform": "Wrapper on vulkan"
209-
}
210-
'''
203+
platforminfo = worker_info_json_string
211204

212205
tryToken = args.token
213206
print("Call getToken()")
@@ -294,6 +287,21 @@ def isDeviceAvailable(serial):
294287

295288
service = None
296289

290+
# Get worker info
291+
worker_info_file = 'worker_info.json'
292+
remove(worker_info_file)
293+
294+
if args.linux:
295+
vkrun.dump_info_linux()
296+
else:
297+
vkrun.dump_info_android()
298+
299+
assert(os.path.exists(worker_info_file))
300+
301+
worker_info_json_string = '{}' # Dummy but valid JSON string
302+
with open(worker_info_file, 'r') as f:
303+
worker_info_json_string = f.read()
304+
297305
# Main loop
298306
while True:
299307

@@ -302,7 +310,7 @@ def isDeviceAvailable(serial):
302310
exit(1)
303311

304312
if not(service):
305-
service, token = get_service(server, args)
313+
service, token = get_service(server, args, worker_info_json_string)
306314

307315
if not(service):
308316
print("Cannot connect to server, retry in a second...")

0 commit comments

Comments
 (0)