-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.py
executable file
·81 lines (61 loc) · 2.15 KB
/
run.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python3
"""Run BIDS curation GUI given input and output directories."""
import os
import json
import datetime
import subprocess as sp
import sys
import argparse
import time
APP_NAME = "bids_curation_gui"
IMAGE = "bids_curation_gui"
def main():
if args.verbose:
print('\nRunning BIDS Curation GUI\n')
if args.shell:
entry = '/bin/bash'
dash_args = 'ti'
else:
entry = 'run.py'
dash_args = 't'
cwd = os.getcwd()
cmds = []
cmd = "docker run --rm --name parcel " + \
"-p 5001:5001 " + \
f"-v {cwd}/{APP_NAME}/static:/usr/src/app/{APP_NAME}/static " + \
f"{IMAGE}:jsdev " + \
"npm run watch -- --hmr-port 5001 "
cmds.append(cmd)
cmd = "docker run --rm --name flask " + \
f"-e FLASK_APP={APP_NAME} " + \
"-e FLASK_DEBUG=1 " + \
"-e SECRET_KEY=dev-key " + \
f"-e INPUT={args.input} " + \
f"-e OUTPUT={args.output} " + \
f"-v {cwd}:/usr/src/app " + \
f"-v {args.input}:/input " + \
f"-v {args.output}:/output " + \
"-p 5000:5000 " + \
"--entrypoint=flask " + \
f"{IMAGE}:pydev " + \
"run -h 0.0.0.0 "
cmds.append(cmd)
for cmd in cmds:
print('Command:\n\n'+cmd+'\n')
command = [ w for w in cmd.split() ]
result = sp.Popen(command, universal_newlines=True)
if args.verbose:
print(f'{cmd.split()[:2]} return code: '+str(result.returncode))
print('output: \n' + str(result.stdout))
time.sleep(10)
print("\n\n\nNow open this link: http://localhost:5000/\n\n\n")
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("input",help="input directory (contains DICOMS)")
parser.add_argument("output",help="output directory")
parser.add_argument("-s", "--shell", action="store_true",
help="run bash in the container instead of run.py.")
parser.add_argument("-v", "--verbose", action="store_true",
help="Print what is going on.")
args = parser.parse_args()
main()