From a798457c43214090abae8a7533b42c0e3babe398 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Mon, 12 Apr 2021 09:53:59 +0200 Subject: [PATCH] Add mising --log-dir argument to wrapper script --- wrapper/ocr | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/wrapper/ocr b/wrapper/ocr index c6e5003..c38b894 100755 --- a/wrapper/ocr +++ b/wrapper/ocr @@ -1,8 +1,6 @@ #!/usr/bin/env python3 # coding=utf-8 -"""A wrapper to execute the OCR pipeline in a Docker container.""" - from argparse import ArgumentParser import os import subprocess @@ -10,8 +8,8 @@ import sys CONTAINER_IMAGE = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/ocr:1.0.0' CONTAINER_INPUT_DIR = '/input' -CONTAINER_LOG_DIR = '/logs' CONTAINER_OUTPUT_DIR = '/output' +CONTAINER_LOG_DIR = '/logs' UID = str(os.getuid()) GID = str(os.getgid()) @@ -22,21 +20,18 @@ parser.add_argument('--log-dir') args, remaining_args = parser.parse_known_args() cmd = ['docker', 'run', '--rm', '-it', '-u', '{}:{}'.format(UID, GID)] -if args.log_dir is not None: - cmd += ['-v', '{}:{}'.format(os.path.abspath(args.log_dir), - CONTAINER_LOG_DIR)] - remaining_args.insert(0, CONTAINER_LOG_DIR) - remaining_args.insert(0, '--log-dir') if args.input_dir is not None: - cmd += ['-v', '{}:{}'.format(os.path.abspath(args.input_dir), - CONTAINER_INPUT_DIR)] - remaining_args.insert(0, CONTAINER_INPUT_DIR) - remaining_args.insert(0, '-i') + mapping = os.path.abspath(args.input_dir) + ':' + CONTAINER_INPUT_DIR + cmd += ['-v', mapping] + remaining_args += ['-i', CONTAINER_INPUT_DIR] if args.output_dir is not None: - cmd += ['-v', '{}:{}'.format(os.path.abspath(args.output_dir), - CONTAINER_OUTPUT_DIR)] - remaining_args.insert(0, CONTAINER_OUTPUT_DIR) - remaining_args.insert(0, '-o') + mapping = os.path.abspath(args.output_dir) + ':' + CONTAINER_OUTPUT_DIR + cmd += ['-v', mapping] + remaining_args += ['-o', CONTAINER_OUTPUT_DIR] +if args.log_dir is not None: + 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 += remaining_args