Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions medcat-demo-app/webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ COPY --from=build /webapp /webapp
# Copy Python site-packages (installed by pip) from build stage
COPY --from=build /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages

# Set environment variables
ENV VOCAB_URL=https://medcat.rosalind.kcl.ac.uk/media/vocab.dat
ENV CDB_URL=https://medcat.rosalind.kcl.ac.uk/media/cdb-medmen-v1.dat

ENV CDB_PATH=/webapp/models/cdb.dat
ENV VOCAB_PATH=/webapp/models/vocab.dat

# Set the pythonpath
WORKDIR /webapp

Expand Down
12 changes: 6 additions & 6 deletions medcat-demo-app/webapp/demo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
from wsgiref.util import FileWrapper
from medcat import __version__ as medcat_version
from medcat.cat import CAT
from medcat.cdb import CDB
from medcat.vocab import Vocab
from urllib.request import urlretrieve, urlopen
from urllib.error import HTTPError
#from medcat.meta_cat import MetaCAT
from .models import *
from .forms import DownloaderForm, UMLSApiKeyForm
from functools import lru_cache

AUTH_CALLBACK_SERVICE = 'https://medcat.rosalind.kcl.ac.uk/auth-callback'
VALIDATION_BASE_URL = 'https://uts-ws.nlm.nih.gov/rest/isValidServiceValidate'
Expand All @@ -29,10 +28,10 @@

model_pack_path = os.getenv('MODEL_PACK_PATH', 'models/medmen_wstatus_2021_oct.zip')

try:
cat = CAT.load_model_pack(model_pack_path)
except Exception as e:
print(str(e))

@lru_cache
def get_model_pack():
return CAT.load_model_pack(model_pack_path)


TPL_ENT = """<mark class="entity" v-on:click="show_info({id})" style="background: {bg}; padding: 0.12em 0.6em; margin: 0 0.25em; line-height: 1; border-radius: 0.35em; box-decoration-break: clone; -webkit-box-decoration-break: clone"> {text} <span style="font-size: 0.8em; font-weight: bold; line-height: 1; border-radius: 0.35em; text-transform: uppercase; vertical-align: middle; margin-left: 0.1rem">{label}</span></mark>"""
Expand Down Expand Up @@ -80,6 +79,7 @@ def fix_floats(in_dict: dict) -> dict:


def get_html_and_json(text):
cat = get_model_pack()
doc = cat(text)

a = {
Expand Down