mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nlp.git
synced 2024-12-26 22:04:18 +00:00
36 lines
1.1 KiB
Python
Executable File
36 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# coding=utf-8
|
|
|
|
import argparse
|
|
import os
|
|
import subprocess
|
|
|
|
container_image = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/nlp:2.1.0'
|
|
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',
|
|
required=False)
|
|
parser.add_argument('-o',
|
|
dest='output_dir',
|
|
required=False)
|
|
args, remaining_args = parser.parse_known_args()
|
|
|
|
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]
|
|
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]
|
|
cmd.append(container_image)
|
|
cmd += remaining_args
|
|
|
|
subprocess.run(cmd)
|