mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nlp.git
synced 2025-01-13 16:40:34 +00:00
Compare commits
2 Commits
72409bd12d
...
4e7669d009
Author | SHA1 | Date | |
---|---|---|---|
|
4e7669d009 | ||
|
8105edfd1b |
31
wrapper/nlp
31
wrapper/nlp
@ -4,30 +4,35 @@
|
|||||||
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-directory')
|
parser.add_argument('-i', '--input-dir')
|
||||||
parser.add_argument('-o', '--output-directory')
|
parser.add_argument('-o', '--output-dir')
|
||||||
|
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.output_directory is not None:
|
if args.input_dir is not None:
|
||||||
cmd += ['-v', '{}:{}'.format(os.path.abspath(args.output_directory),
|
mapping = os.path.abspath(args.input_dir) + ':' + CONTAINER_INPUT_DIR
|
||||||
CONTAINER_OUTPUT_DIR)]
|
cmd += ['-v', mapping]
|
||||||
remaining_args.insert(0, CONTAINER_OUTPUT_DIR)
|
remaining_args += ['-i', CONTAINER_INPUT_DIR]
|
||||||
remaining_args.insert(0, '-o')
|
if args.output_dir is not None:
|
||||||
if args.input_directory is not None:
|
mapping = os.path.abspath(args.output_dir) + ':' + CONTAINER_OUTPUT_DIR
|
||||||
cmd += ['-v', '{}:{}'.format(os.path.abspath(args.input_directory),
|
cmd += ['-v', mapping]
|
||||||
CONTAINER_INPUT_DIR)]
|
remaining_args += ['-o', CONTAINER_OUTPUT_DIR]
|
||||||
remaining_args.insert(0, CONTAINER_INPUT_DIR)
|
if args.log_dir is not None:
|
||||||
remaining_args.insert(0, '-i')
|
mapping = os.path.abspath(args.log_dir) + ':' + CONTAINER_LOG_DIR
|
||||||
|
cmd += ['-v', mapping]
|
||||||
|
remaining_args += ['--log-dir', CONTAINER_LOG_DIR]
|
||||||
cmd.append(CONTAINER_IMAGE)
|
cmd.append(CONTAINER_IMAGE)
|
||||||
cmd += remaining_args
|
cmd += remaining_args
|
||||||
|
|
||||||
subprocess.run(cmd)
|
sys.exit(subprocess.run(cmd).returncode)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user