nlp/wrapper/nlp

40 lines
1.0 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env python3
# coding=utf-8
import argparse
2019-06-03 11:32:37 +00:00
import os
import subprocess
container_image = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/nlp:latest'
2019-06-03 11:32:37 +00:00
container_input_dir = '/input'
container_output_dir = '/output'
uid = str(os.getuid())
gid = str(os.getgid())
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument(
'-i',
dest='input_dir',
2019-06-03 12:18:23 +00:00
required=False
)
parser.add_argument(
'-o',
dest='output_dir',
2019-06-03 12:18:23 +00:00
required=False
)
2019-06-03 11:32:37 +00:00
args, remaining_args = parser.parse_known_args()
2019-06-03 11:32:37 +00:00
cmd = ['docker', 'run', '--rm', '-it', '-u', uid + ':' + gid]
if args.input_dir is not None:
host_input_dir = os.path.abspath(args.input_dir)
cmd += ['-v', host_input_dir + ':' + container_input_dir]
remaining_args += ['-i', container_input_dir]
2019-06-03 11:32:37 +00:00
if args.output_dir is not None:
host_output_dir = os.path.abspath(args.output_dir)
cmd += ['-v', host_output_dir + ':' + container_output_dir]
remaining_args += ['-o', container_output_dir]
2019-06-02 19:38:47 +00:00
cmd.append(container_image)
2019-06-03 11:32:37 +00:00
cmd += remaining_args
2019-06-02 19:38:47 +00:00
subprocess.run(cmd)