Skip to content

Commit

Permalink
Downloads stanza models earlier
Browse files Browse the repository at this point in the history
Also includes updated dockerfiles
  • Loading branch information
benknoll-umn committed Oct 3, 2022
1 parent bd66d35 commit dc9b743
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 10 deletions.
19 changes: 13 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:latest
FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive

Expand All @@ -9,11 +9,18 @@ RUN apt-get -qy install openjdk-11-jre-headless
RUN apt-get -qy install build-essential
RUN apt-get -qy install python3 python3-pip

COPY . /home/biomedicus3/biomedicus3

WORKDIR /home/biomedicus3

RUN pip3 install ./biomedicus3
RUN biomedicus download-data
RUN pip3 install --upgrade pip
RUN python3 -m pip install --upgrade setuptools

RUN pip3 install biomedicus3
RUN biomedicus download-data --with-stanza

COPY ./python/biomedicus/deployment/biomedicus_deploy_config.yml .
COPY ./python/biomedicus/pipeline/biomedicus_default_pipeline.yml .
COPY ./tools/docker/biomedicus.sh .

RUN chmod +x biomedicus.sh

CMD /bin/sh
ENTRYPOINT ./biomedicus.sh
28 changes: 28 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update

RUN apt-get -qy install git
RUN apt-get -qy install openjdk-11-jdk-headless
RUN apt-get -qy install build-essential
RUN apt-get -qy install python3 python3-pip

WORKDIR /home/biomedicus3

RUN pip3 install --upgrade pip
RUN python3 -m pip install --upgrade setuptools

COPY . biomedicus3

RUN pip3 install ./biomedicus3
RUN biomedicus download-data --with-stanza

COPY ./python/biomedicus/deployment/biomedicus_deploy_config.yml .
COPY ./python/biomedicus/pipeline/biomedicus_default_pipeline.yml .
COPY ./tools/docker/biomedicus.sh .

RUN chmod +x biomedicus.sh

ENTRYPOINT ./biomedicus.sh
1 change: 1 addition & 0 deletions python/biomedicus/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def write_config_subparser(subparsers):
def download_data_subparser(subparsers):
from biomedicus.deployment.deploy_biomedicus import download_data
sp = subparsers.add_parser('download-data', help="Just downloads the biomedicus data.")
sp.add_argument('--with-stanza', action='store_true', help="Also downloads stanza models.")
sp.set_defaults(f=download_data)


Expand Down
1 change: 1 addition & 0 deletions python/biomedicus/deployment/biomedicus_deploy_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ processors:
entry_point: biomedicus.dependencies.stanza_selective_parser
port: 50800
startup_timeout: 180
additional_args: ['--offline']
- implementation: python
entry_point: biomedicus.negation.deepen
port: 50900
Expand Down
12 changes: 8 additions & 4 deletions python/biomedicus/deployment/deploy_biomedicus.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ def _listen(process: Popen) -> int:
return process.wait()


def check_data(download=False):
def check_data(download=False, with_stanza=False):
try:
data = Path(os.environ['BIOMEDICUS_DATA'])
except KeyError:
data = Path.home() / '.biomedicus' / 'data'
os.environ['BIOMEDICUS_DATA'] = str(data)

if with_stanza:
import stanza
stanza.download('en')

config = load_config()
download_url = config['data.data_url']
data_version = config['data.version']
Expand Down Expand Up @@ -105,7 +109,7 @@ def attach_biomedicus_jar(deployment: Deployment, append_to: Optional[str] = Non

def deploy(conf):
try:
check_data(conf.download_data)
check_data(conf.download_data, with_stanza=True)
except ValueError:
return
deployment = Deployment.from_yaml_file(conf.config)
Expand All @@ -118,9 +122,9 @@ def deploy(conf):
deployment.run_servers()


def download_data(_):
def download_data(conf):
try:
check_data(True)
check_data(True, conf.with_stanza)
except ValueError:
return

Expand Down
6 changes: 6 additions & 0 deletions tools/docker/biomedicus.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

exec 3< <(biomedicus deploy --config biomedicus_deploy_config.yml)
sed '/Done deploying all servers.$/q' <&3 ; cat <&3 &

biomedicus run /input --watch -o /output --config biomedicus_default_pipeline.yml

0 comments on commit dc9b743

Please sign in to comment.