-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
55 lines (44 loc) · 1.63 KB
/
install.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
import json
import os
import argparse
import subprocess
from multiprocessing import Pool
def build(library, args):
"""
Install a docker container
"""
print('Building %s...' % library)
if args is not None and len(args) != 0:
q = " ".join(["--build-arg " + x.replace(" ", "\\ ") for x in args])
else:
q = ""
try:
subprocess.check_call(
'docker build %s --rm -t df-benchmarks-%s -f'
' install/Dockerfile.%s .' % (q, library, library), shell=True)
return {library: 'success'}
except subprocess.CalledProcessError:
return {library: 'fail'}
if __name__ == "__main__":
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'--algorithm',
metavar='NAME',
help='build only the named algorithm image',
default=None)
parser.add_argument(
'--build-arg',
help='pass given args to all docker builds',
nargs="+")
args = parser.parse_args()
print('Downloading ubuntu container...')
subprocess.check_call('docker pull ubuntu:18.04', shell=True)
print('Building base image...')
subprocess.check_call('docker build --rm -t df-benchmarks -f install/Dockerfile .', shell=True)
if args.algorithm:
tags = [args.algorithm]
else:
tags = [fn.split('.')[-1] for fn in os.listdir('install') if fn.startswith('Dockerfile.')]
print('Building algorithm images...')
install_status = [build(tag, args.build_arg) for tag in tags]
print('\n\nInstall Status:\n' + '\n'.join(str(algo) for algo in install_status))