From bd63f207411358a693e907efc167fca5f31697ed Mon Sep 17 00:00:00 2001 From: tomolopolis Date: Fri, 14 Jul 2023 17:34:52 +0100 Subject: [PATCH] CU-863h6ca0d: new feature to click through to annotation dataset from the TPs, FNs, FPs page, some extra warnings on the metrics API in case weird requests come in --- webapp/api/api/views.py | 13 ++++- webapp/frontend/src/App.vue | 1 - .../src/components/anns/AnnoResult.vue | 22 +++++++-- webapp/frontend/src/views/Home.vue | 9 ++-- webapp/frontend/src/views/Metrics.vue | 47 +++++++++++++++---- .../frontend/src/views/TrainAnnotations.vue | 9 ++++ 6 files changed, 83 insertions(+), 18 deletions(-) diff --git a/webapp/api/api/views.py b/webapp/api/api/views.py index 2bcb8764..e4af3c97 100644 --- a/webapp/api/api/views.py +++ b/webapp/api/api/views.py @@ -636,7 +636,18 @@ def model_loaded(_): def metrics(request): p_ids = request.GET.get('projectIds').split(',') projects = ProjectAnnotateEntities.objects.filter(id__in=p_ids) - # assume projects all use the same model for eval purposes. + + # provide warning of inconsistent models used or for models that are not loaded. + p_cdbs = set(p.concept_db for p in projects) + if len(p_cdbs) > 1: + logger.warning('Inconsistent CDBs used in the generation of metrics - should use the same CDB for ' + f'consistent results - found {[cdb.name for cdb in p_cdbs]} - metrics will only use the first' + f' CDB {projects[0].concept_db.name}') + for p_cdb in p_cdbs: + if p_cdb not in CDB_MAP: + logger.warning(f'CDB {p_cdb.name} not in CDB_MAP cache - this will now be loaded - ' + f'and will not show intermediary training status') + cat = get_medcat(CDB_MAP=CDB_MAP, VOCAB_MAP=VOCAB_MAP, CAT_MAP=CAT_MAP, project=projects[0]) project_data = retrieve_project_data(projects) diff --git a/webapp/frontend/src/App.vue b/webapp/frontend/src/App.vue index 1aefe0a7..963fa4f7 100644 --- a/webapp/frontend/src/App.vue +++ b/webapp/frontend/src/App.vue @@ -109,7 +109,6 @@ export default { } .link { - //padding-top: 10px; display:inline-block; height: 25px; cursor: pointer; diff --git a/webapp/frontend/src/components/anns/AnnoResult.vue b/webapp/frontend/src/components/anns/AnnoResult.vue index 1d4e1b22..19ef15de 100644 --- a/webapp/frontend/src/components/anns/AnnoResult.vue +++ b/webapp/frontend/src/components/anns/AnnoResult.vue @@ -3,7 +3,7 @@ {{result['document name']}} {{result.cui}} {{result['source value']}} - {{result.acc}} + {{Number(result.acc).toFixed(3)}} @@ -33,7 +33,6 @@ export default { if (this.type === 'fp' || this.type === 'fn') { highlightClass = 'highlight-task-1' } - const srcVal = this.result['source value'] const resTxt = this.result.text const regexp = RegExp(`${srcVal}`, 'sg') @@ -45,13 +44,30 @@ export default { } else { outText += `${resTxt.slice(matches[matches.indexOf(match) - 1].index + srcVal.length, match.index)}` } - outText += `${srcVal}` + outText += `${srcVal}` if (matches.length === 1 || match === matches[-1]) { outText += `${resTxt.slice(match.index + srcVal.length)}` } } return outText } + }, + methods: { + openAnno () { + const routeData = this.$router.resolve( + { + name: 'train-annotations', + params: { + projectId: this.result['project id'], + docId: this.result['document id'], + }, + query: { + annoStart: this.result['start'], + annoEnd: this.result['end'] + } + }) + window.open(routeData.href, '_blank'); + } } } diff --git a/webapp/frontend/src/views/Home.vue b/webapp/frontend/src/views/Home.vue index 4d8edbdb..ba5a5d96 100644 --- a/webapp/frontend/src/views/Home.vue +++ b/webapp/frontend/src/views/Home.vue @@ -13,10 +13,14 @@ v-if="!loadingProjects" @row-selected="select">