From 195c4bd81eda6f2128d1bb6bb0c26edc83c39567 Mon Sep 17 00:00:00 2001 From: rjawesome Date: Mon, 21 Oct 2024 15:43:57 -0700 Subject: [PATCH 1/4] do not allow edge attribtues with same type id for trapi --- src/graph/knowledge_graph.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/graph/knowledge_graph.ts b/src/graph/knowledge_graph.ts index a3a4cc6..da84614 100644 --- a/src/graph/knowledge_graph.ts +++ b/src/graph/knowledge_graph.ts @@ -175,6 +175,7 @@ export default class KnowledgeGraph { //handle TRAPI APIs (Situation A of https://github.com/biothings/BioThings_Explorer_TRAPI/issues/208) and APIs that define 'edge-atributes' in x-bte const seenPmids = new Set(); + const seenAttrs = new Set(); kgEdge.attributes['edge-attributes']?.forEach((attribute) => { // Do not add multiple SemmedDB sentences/other "supporting study results" from the same publication if (attribute.attribute_type_id === "biolink:has_supporting_study_result" && attribute?.attributes?.find((attr) => attr.attribute_type_id === "biolink:publications")) { @@ -186,7 +187,11 @@ export default class KnowledgeGraph { } seenPmids.add(publication); } - + // Do not add duplicate attributes for TRAPi + else if (seenAttrs.has(attribute.attribute_type_id)) { + return; + } + seenAttrs.add(attribute.attribute_type_id); attributes.push(attribute); }); From 3efc3f2e210e16da31e2324be749ff8f84363c6e Mon Sep 17 00:00:00 2001 From: Jackson Callaghan <43009413+tokebe@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:23:38 -0400 Subject: [PATCH 2/4] Revert "do not allow edge attribtues with same type id for trapi" --- src/graph/knowledge_graph.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/graph/knowledge_graph.ts b/src/graph/knowledge_graph.ts index da84614..a3a4cc6 100644 --- a/src/graph/knowledge_graph.ts +++ b/src/graph/knowledge_graph.ts @@ -175,7 +175,6 @@ export default class KnowledgeGraph { //handle TRAPI APIs (Situation A of https://github.com/biothings/BioThings_Explorer_TRAPI/issues/208) and APIs that define 'edge-atributes' in x-bte const seenPmids = new Set(); - const seenAttrs = new Set(); kgEdge.attributes['edge-attributes']?.forEach((attribute) => { // Do not add multiple SemmedDB sentences/other "supporting study results" from the same publication if (attribute.attribute_type_id === "biolink:has_supporting_study_result" && attribute?.attributes?.find((attr) => attr.attribute_type_id === "biolink:publications")) { @@ -187,11 +186,7 @@ export default class KnowledgeGraph { } seenPmids.add(publication); } - // Do not add duplicate attributes for TRAPi - else if (seenAttrs.has(attribute.attribute_type_id)) { - return; - } - seenAttrs.add(attribute.attribute_type_id); + attributes.push(attribute); }); From 2496be39df23ab4ff2ea81751c700d175637e1a2 Mon Sep 17 00:00:00 2001 From: Jackson Callaghan <43009413+tokebe@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:25:01 -0400 Subject: [PATCH 3/4] Revert "properly merge semmedb sentences" --- src/graph/kg_edge.ts | 3 +-- src/graph/knowledge_graph.ts | 26 -------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/graph/kg_edge.ts b/src/graph/kg_edge.ts index bc45111..14ec7c4 100644 --- a/src/graph/kg_edge.ts +++ b/src/graph/kg_edge.ts @@ -120,8 +120,7 @@ export default class KGEdge { addAdditionalAttributes(name: string, value: string | string[] | TrapiAttribute[]): void { // special handling for full edge attributes if (name === 'edge-attributes') { - if (this.attributes[name]) this.attributes[name] = [...this.attributes[name], ...value as TrapiAttribute[]]; - else this.attributes[name] = value as TrapiAttribute[]; + this.attributes[name] = value as TrapiAttribute[]; return; } diff --git a/src/graph/knowledge_graph.ts b/src/graph/knowledge_graph.ts index a3a4cc6..c5f2b87 100644 --- a/src/graph/knowledge_graph.ts +++ b/src/graph/knowledge_graph.ts @@ -174,35 +174,9 @@ export default class KnowledgeGraph { }); //handle TRAPI APIs (Situation A of https://github.com/biothings/BioThings_Explorer_TRAPI/issues/208) and APIs that define 'edge-atributes' in x-bte - const seenPmids = new Set(); kgEdge.attributes['edge-attributes']?.forEach((attribute) => { - // Do not add multiple SemmedDB sentences/other "supporting study results" from the same publication - if (attribute.attribute_type_id === "biolink:has_supporting_study_result" && attribute?.attributes?.find((attr) => attr.attribute_type_id === "biolink:publications")) { - const publication = attribute.attributes.find((attr) => attr.attribute_type_id === "biolink:publications").value; - // publication has been seen or cap reached - if (seenPmids.has(publication) || seenPmids.size >= 50) { - seenPmids.add(publication); - return; - } - seenPmids.add(publication); - } - attributes.push(attribute); }); - - // update evidence count after PMIDs have been merged (for SemmedDB) - if (seenPmids.size != 0) { - const evidenceAttr = attributes.find(attr => attr.attribute_type_id === 'biolink:evidence_count'); - if (evidenceAttr) { - evidenceAttr.value = seenPmids.size; - } else { - attributes.push({ - attribute_type_id: 'biolink:evidence_count', - value: seenPmids.size, - }); - } - } - return attributes; } From 9eabfa1af16c36ac6d97ec18ba841f43424fead5 Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:33:20 -0400 Subject: [PATCH 4/4] chore: lower template time (4:45 -> 4:30) Should give a little more time for wrapup (PFOCR aug, callback in the case of heavy responses, etc) --- src/inferred_mode/inferred_mode.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inferred_mode/inferred_mode.ts b/src/inferred_mode/inferred_mode.ts index 92db3c5..4828da4 100644 --- a/src/inferred_mode/inferred_mode.ts +++ b/src/inferred_mode/inferred_mode.ts @@ -88,7 +88,7 @@ export default class InferredQueryHandler { this.CREATIVE_LIMIT = process.env.CREATIVE_LIMIT ? parseInt(process.env.CREATIVE_LIMIT) : 500; this.CREATIVE_TIMEOUT = process.env.CREATIVE_TIMEOUT_S ? parseInt(process.env.CREATIVE_TIMEOUT) * 1000 - : 4.75 * 60 * 1000; + : 4.50 * 60 * 1000; } get queryIsValid(): boolean {