File tree Expand file tree Collapse file tree 2 files changed +6
-13
lines changed Expand file tree Collapse file tree 2 files changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -55,13 +55,6 @@ COPY --from=build /webapp /webapp
5555# Copy Python site-packages (installed by pip) from build stage
5656COPY --from=build /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
5757
58- # Set environment variables
59- ENV VOCAB_URL=https://medcat.rosalind.kcl.ac.uk/media/vocab.dat
60- ENV CDB_URL=https://medcat.rosalind.kcl.ac.uk/media/cdb-medmen-v1.dat
61-
62- ENV CDB_PATH=/webapp/models/cdb.dat
63- ENV VOCAB_PATH=/webapp/models/vocab.dat
64-
6558# Set the pythonpath
6659WORKDIR /webapp
6760
Original file line number Diff line number Diff line change 1010from wsgiref .util import FileWrapper
1111from medcat import __version__ as medcat_version
1212from medcat .cat import CAT
13- from medcat .cdb import CDB
14- from medcat .vocab import Vocab
1513from urllib .request import urlretrieve , urlopen
1614from urllib .error import HTTPError
1715#from medcat.meta_cat import MetaCAT
1816from .models import *
1917from .forms import DownloaderForm , UMLSApiKeyForm
18+ from functools import lru_cache
2019
2120AUTH_CALLBACK_SERVICE = 'https://medcat.rosalind.kcl.ac.uk/auth-callback'
2221VALIDATION_BASE_URL = 'https://uts-ws.nlm.nih.gov/rest/isValidServiceValidate'
2928
3029model_pack_path = os .getenv ('MODEL_PACK_PATH' , 'models/medmen_wstatus_2021_oct.zip' )
3130
32- try :
33- cat = CAT . load_model_pack ( model_pack_path )
34- except Exception as e :
35- print ( str ( e ) )
31+
32+ @ lru_cache
33+ def get_model_pack () :
34+ return CAT . load_model_pack ( model_pack_path )
3635
3736
3837TPL_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>"""
@@ -80,6 +79,7 @@ def fix_floats(in_dict: dict) -> dict:
8079
8180
8281def get_html_and_json (text ):
82+ cat = get_model_pack ()
8383 doc = cat (text )
8484
8585 a = {
You can’t perform that action at this time.
0 commit comments