Skip to content

Commit

Permalink
Dockerfile update(s) + pep8 fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
vladd-bit committed Feb 19, 2024
1 parent 607ad1c commit f00a74a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1
WORKDIR /cat
COPY ./medcat_service/requirements.txt /cat
RUN pip install --upgrade pip

# Install requirements for the app
RUN pip install -r requirements.txt
RUN pip3 install --no-cache-dir -r requirements.txt

# Get the spacy model
ARG SPACY_MODELS="en_core_web_sm en_core_web_md en_core_web_lg"
Expand Down
9 changes: 7 additions & 2 deletions Dockerfile_gpu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ RUN echo "deb-src http://deb.debian.org/debian bookworm-backports main contrib n

RUN apt-get update && apt-get upgrade -y && \
apt-get install -y software-properties-common

# NVIDIA Docker
RUN export distribution=$(. /etc/os-release;echo $ID$VERSION_ID)

Expand All @@ -26,13 +25,19 @@ RUN apt-get update && apt-get upgrade -y

RUN apt-get install -y nvidia-container-toolkit nvidia-docker2

# clean up apt
RUN apt-get clean autoclean && apt-get autoremove --purge -y

# Set the python path and preapre the base layer
WORKDIR /cat
COPY ./medcat_service/requirements.txt /cat
RUN pip install --upgrade pip

# clean up pip
RUN pip3 cache purge

# Install requirements for the app
RUN pip install -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Get the spacy model
ARG SPACY_MODELS="en_core_web_sm en_core_web_md en_core_web_lg"
Expand Down
2 changes: 0 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ def post_fork(server, worker):
os.environ["CUDA_VISIBLE_DEVICES"] = str(cudaid)
else:
worker.log.info("APP_CUDA_DEVICE_COUNT device variables not set")


23 changes: 12 additions & 11 deletions medcat_service/nlp_processor/medcat_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class NlpProcessor:
"""
This class defines an interface for NLP Processor
"""

def __init__(self):
app_log_level = os.getenv("APP_LOG_LEVEL", logging.INFO)
medcat_log_level = os.getenv("LOG_LEVEL", logging.INFO)
Expand Down Expand Up @@ -114,10 +115,10 @@ def process_content(self, content):
if "text" not in content:
error_msg = "'text' field missing in the payload content."
nlp_result = {
"success": False,
"errors": [error_msg],
"timestamp": NlpProcessor._get_timestamp(),
}
"success": False,
"errors": [error_msg],
"timestamp": NlpProcessor._get_timestamp(),
}

return nlp_result

Expand All @@ -138,12 +139,12 @@ def process_content(self, content):
entities = self.process_entities(entities)

nlp_result = {
"text": str(text),
"annotations": entities,
"success": True,
"timestamp": NlpProcessor._get_timestamp(),
"elapsed_time": elapsed_time
}
"text": str(text),
"annotations": entities,
"success": True,
"timestamp": NlpProcessor._get_timestamp(),
"elapsed_time": elapsed_time
}

# append the footer
if "footer" in content:
Expand Down Expand Up @@ -187,7 +188,7 @@ def process_content_bulk(self, content):
ann_res = self.cat.deid_text()
else:
ann_res = self.cat.multiprocessing_batch_docs_size(
MedCatProcessor._generate_input_doc(content, invalid_doc_ids), batch_size = batch_size, nproc=nproc)
MedCatProcessor._generate_input_doc(content, invalid_doc_ids), batch_size=batch_size, nproc=nproc)

except Exception as e:
self.log.error(repr(e))
Expand Down

0 comments on commit f00a74a

Please sign in to comment.