-
Notifications
You must be signed in to change notification settings - Fork 27
/
main.py
44 lines (34 loc) · 1.53 KB
/
main.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
import json
import os
import sys
from utils import run
def main():
pr_id = int(sys.argv[1])
print(f'pr_id: {pr_id}')
with open('settings.json', 'r') as f:
settings = json.load(f)
with open('validation_performance.json', 'r') as f:
settings.update(json.load(f))
if settings.get('download_url'):
# download image from set url instead of upload form
run(['wget', settings['download_url'], '-O', f'/submissions/fishyscapes_pr_{pr_id}', '-o', '/tmp/wget_output.log'])
try:
run(['cp', os.path.join('/submissions', f'fishyscapes_pr_{pr_id}'), os.path.join('/tmp', f'fishyscapes_pr_{pr_id}.simg')])
except AssertionError:
raise UserWarning("Failed to copy singularity container. Have you uploaded a container following the website instructions?")
run(['mkdir', '-p', settings['tmp_pred_path']])
run(['chmod', '777', settings['tmp_pred_path']])
run(' '.join(['rm', '-rf', os.path.join(settings['tmp_pred_path'], '*')]), shell=True)
cmd = [
'singularity', 'run', '--nv',
'--bind', f"{settings['tmp_pred_path']}:/output,"
f"{settings['val_rgb_path']}:/input",
os.path.join('/tmp', f'fishyscapes_pr_{pr_id}.simg')
]
try:
run(['runuser', '-l', 'blumh', '-c', ' '.join(cmd)])
except AssertionError:
raise UserWarning("Execution of submitted container failed. Please take a look at the logs and resubmit a new container.")
run(['ls', settings['tmp_pred_path']])
if __name__ == '__main__':
main()