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
3 changes: 3 additions & 0 deletions medcat-trainer/envs/env
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ EMAIL_USER=example@cogstack.org
EMAIL_PASS="to be changed"
EMAIL_HOST=mail.cogstack.org
EMAIL_PORT=465

# Remote model service timeout in seconds
REMOTE_MODEL_SERVICE_TIMEOUT=60
5 changes: 4 additions & 1 deletion medcat-trainer/envs/env-prod
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ LOAD_NUM_DOC_PAGES=10
EMAIL_USER=example@cogstack.org
EMAIL_PASS="to be changed"
EMAIL_HOST=mail.cogstack.org
EMAIL_PORT=465
EMAIL_PORT=465

# Remote model service timeout in seconds
REMOTE_MODEL_SERVICE_TIMEOUT=60
5 changes: 4 additions & 1 deletion medcat-trainer/webapp/api/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ def call_remote_model_service(service_url, text):
"text": text
}

# Get timeout from environment variable, default to 60 seconds
timeout = int(os.getenv('REMOTE_MODEL_SERVICE_TIMEOUT', '60'))

try:
response = requests.post(api_url, json=payload, timeout=60)
response = requests.post(api_url, json=payload, timeout=timeout)
response.raise_for_status()
result = response.json()

Expand Down
8 changes: 4 additions & 4 deletions medcat-trainer/webapp/api/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from rest_framework.response import Response
from medcat.components.ner.trf.deid import DeIdModel
from medcat.utils.cdb_utils import ch2pt_from_pt2ch, get_all_ch, snomed_ct_concept_path
from medcat.utils.config_utils import temp_changed_config


from .admin import download_projects_with_text, download_projects_without_text, \
import_concepts_from_cdb
Expand Down Expand Up @@ -678,10 +680,8 @@ def annotate_text(request):
logger.warning(f'Failed to get children for CUI {parent_cui}: {e}')
cuis_set = expanded_cuis

curr_cuis = cat.config.components.linking.filters
cat.config.components.linking.filters.cuis = cuis_set
spacy_doc = cat(message)
cat.config.components.linking.filters = curr_cuis
with temp_changed_config(cat.config.components.linking, 'filters', cuis_set):
spacy_doc = cat(message)

ents = []
anno_tkns = []
Expand Down