Update for unprivileged usage.

This commit is contained in:
Patrick Jentsch 2019-06-02 21:38:47 +02:00
parent bc28f8a8b4
commit 6ddfd51ba9
3 changed files with 22 additions and 18 deletions

View File

@ -37,4 +37,7 @@ RUN pip3 install wheel && pip3 install -U spacy && \
COPY nlp /usr/local/bin
COPY spacy_nlp /usr/local/bin
mkdir /input /output
chmod a+rw /input /output
ENTRYPOINT ["nlp"]

View File

@ -44,12 +44,12 @@ mkdir -p /<mydatalocation>/files_for_nlp /<mydatalocation>/files_from_nlp
docker run \
--rm \
-it \
-v /<mydatalocation>/files_for_nlp:/files_for_nlp \
-v /<mydatalocation>/files_from_nlp:/files_from_nlp \
-v /<mydatalocation>/files_for_nlp:/input \
-v /<mydatalocation>/files_from_nlp:/output \
sfb1288inf/nlp:latest \
-i /files_for_nlp \
-o /files_from_nlp \
-l <languagecode>
-i /input \
-l <languagecode> \
-o /output
```
The arguments below `sfb1288inf/nlp:latest` are described in the [NLP arguments](#nlp-arguments) part.

View File

@ -10,22 +10,23 @@ parser = argparse.ArgumentParser(add_help=False)
parser.add_argument(
'-i',
dest='input_dir',
required=False
required=True
)
parser.add_argument(
'-o',
dest='output_dir',
required=False
required=True
)
args, nlp_args = parser.parse_known_args()
dirs, args = parser.parse_known_args()
if args.input_dir == None or args.output_dir == None:
if args.input_dir != None:
nlp_args.append('-i')
nlp_args.append('/files_for_nlp')
if args.output_dir != None:
nlp_args.append('-o')
nlp_args.append('/files_from_nlp')
subprocess.run(['docker', 'run', '--rm', '-it', container_image] + nlp_args)
else:
subprocess.run(['docker', 'run', '--rm', '-it', '-v', args.input_dir + ':/files_for_nlp', '-v', args.output_dir + ':/files_from_nlp', container_image, '-i', '/files_for_nlp', '-o', '/files_from_nlp'] + nlp_args)
cmd = ['docker', 'run', '--rm', '-it']
if dirs.input_dir is not None:
cmd += ['-v', dirs.input_dir + ':/input']
args += ['-i', '/input']
if dirs.output_dir is not None:
cmd += ['-v', dirs.output_dir + ':/output']
args += ['-o', '/output']
cmd.append(container_image)
cmd += args
subprocess.run(cmd)