Compare commits

..

No commits in common. "4e7669d009db4c35ad4b253241e809b8d5005445" and "72409bd12d5d55c9a4aa679ff93b615375bc524d" have entirely different histories.

View File

@ -4,35 +4,30 @@
from argparse import ArgumentParser from argparse import ArgumentParser
import os import os
import subprocess import subprocess
import sys
CONTAINER_IMAGE = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/nlp:1.0.0' CONTAINER_IMAGE = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/nlp:1.0.0'
CONTAINER_INPUT_DIR = '/input' CONTAINER_INPUT_DIR = '/input'
CONTAINER_OUTPUT_DIR = '/output' CONTAINER_OUTPUT_DIR = '/output'
CONTAINER_LOG_DIR = '/logs'
UID = str(os.getuid()) UID = str(os.getuid())
GID = str(os.getgid()) GID = str(os.getgid())
parser = ArgumentParser(add_help=False) parser = ArgumentParser(add_help=False)
parser.add_argument('-i', '--input-dir') parser.add_argument('-i', '--input-directory')
parser.add_argument('-o', '--output-dir') parser.add_argument('-o', '--output-directory')
parser.add_argument('--log-dir')
args, remaining_args = parser.parse_known_args() args, remaining_args = parser.parse_known_args()
cmd = ['docker', 'run', '--rm', '-it', '-u', '{}:{}'.format(UID, GID)] cmd = ['docker', 'run', '--rm', '-it', '-u', '{}:{}'.format(UID, GID)]
if args.input_dir is not None: if args.output_directory is not None:
mapping = os.path.abspath(args.input_dir) + ':' + CONTAINER_INPUT_DIR cmd += ['-v', '{}:{}'.format(os.path.abspath(args.output_directory),
cmd += ['-v', mapping] CONTAINER_OUTPUT_DIR)]
remaining_args += ['-i', CONTAINER_INPUT_DIR] remaining_args.insert(0, CONTAINER_OUTPUT_DIR)
if args.output_dir is not None: remaining_args.insert(0, '-o')
mapping = os.path.abspath(args.output_dir) + ':' + CONTAINER_OUTPUT_DIR if args.input_directory is not None:
cmd += ['-v', mapping] cmd += ['-v', '{}:{}'.format(os.path.abspath(args.input_directory),
remaining_args += ['-o', CONTAINER_OUTPUT_DIR] CONTAINER_INPUT_DIR)]
if args.log_dir is not None: remaining_args.insert(0, CONTAINER_INPUT_DIR)
mapping = os.path.abspath(args.log_dir) + ':' + CONTAINER_LOG_DIR remaining_args.insert(0, '-i')
cmd += ['-v', mapping]
remaining_args += ['--log-dir', CONTAINER_LOG_DIR]
cmd.append(CONTAINER_IMAGE) cmd.append(CONTAINER_IMAGE)
cmd += remaining_args cmd += remaining_args
sys.exit(subprocess.run(cmd).returncode) subprocess.run(cmd)