mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nlp.git
synced 2024-12-27 12:54:18 +00:00
Update for unprivileged usage 2
This commit is contained in:
parent
737a1db496
commit
c5ce5b1c87
@ -44,6 +44,7 @@ mkdir -p /<mydatalocation>/files_for_nlp /<mydatalocation>/files_from_nlp
|
|||||||
docker run \
|
docker run \
|
||||||
--rm \
|
--rm \
|
||||||
-it \
|
-it \
|
||||||
|
-u $(id -u $USER):$(id -g $USER) \
|
||||||
-v /<mydatalocation>/files_for_nlp:/input \
|
-v /<mydatalocation>/files_for_nlp:/input \
|
||||||
-v /<mydatalocation>/files_from_nlp:/output \
|
-v /<mydatalocation>/files_from_nlp:/output \
|
||||||
sfb1288inf/nlp:latest \
|
sfb1288inf/nlp:latest \
|
||||||
|
25
wrapper/nlp
25
wrapper/nlp
@ -2,9 +2,14 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
container_image = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/nlp:latest'
|
container_image = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/nlp:latest'
|
||||||
|
container_input_dir = '/input'
|
||||||
|
container_output_dir = '/output'
|
||||||
|
uid = str(os.getuid())
|
||||||
|
gid = str(os.getgid())
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(add_help=False)
|
parser = argparse.ArgumentParser(add_help=False)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@ -17,16 +22,18 @@ parser.add_argument(
|
|||||||
dest='output_dir',
|
dest='output_dir',
|
||||||
required=True
|
required=True
|
||||||
)
|
)
|
||||||
dirs, args = parser.parse_known_args()
|
args, remaining_args = parser.parse_known_args()
|
||||||
|
|
||||||
cmd = ['docker', 'run', '--rm', '-it']
|
cmd = ['docker', 'run', '--rm', '-it', '-u', uid + ':' + gid]
|
||||||
if dirs.input_dir is not None:
|
if args.input_dir is not None:
|
||||||
cmd += ['-v', dirs.input_dir + ':/input']
|
host_input_dir = os.path.abspath(args.input_dir)
|
||||||
args += ['-i', '/input']
|
cmd += ['-v', host_input_dir + ':' + container_input_dir]
|
||||||
if dirs.output_dir is not None:
|
remaining_args += ['-i', '/input']
|
||||||
cmd += ['-v', dirs.output_dir + ':/output']
|
if args.output_dir is not None:
|
||||||
args += ['-o', '/output']
|
host_output_dir = os.path.abspath(args.output_dir)
|
||||||
|
cmd += ['-v', host_output_dir + ':' + container_output_dir]
|
||||||
|
remaining_args += ['-o', '/output']
|
||||||
cmd.append(container_image)
|
cmd.append(container_image)
|
||||||
cmd += args
|
cmd += remaining_args
|
||||||
|
|
||||||
subprocess.run(cmd)
|
subprocess.run(cmd)
|
||||||
|
Loading…
Reference in New Issue
Block a user