From e8a1790482a210d347d1fa18f340daf3ce1f71e5 Mon Sep 17 00:00:00 2001 From: Eric Zhou Date: Wed, 17 Aug 2022 10:27:46 -0700 Subject: [PATCH 1/3] feat: add diagram of query handling --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/README.md b/README.md index 9954275f..fcf08c7c 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,59 @@ TRAPI stands for [Translator Reasoner API](https://github.com/NCATSTranslator/Re We maintain a live instance of this application at https://api.bte.ncats.io/ that can be used for testing. Query Examples can be found [here](/examples). +### Trapi API Implementation +```mermaid +sequenceDiagram +autonumber +participant I as index.js - query() +participant QG as query_graph.js +participant BEQ as batch_edge_query.js +participant Q2A as qedge2apiedge.js +participant R as query_results.js +participant C as call-apis + + +I->>QG: processQueryGraph() +QG->>QG: Process TRAPI Query Graph Object into
internal qEdge and qXEdge representation +note right of QG: qEdge - Edge in TRAPI query graph
qXEdge - Internal UpdatedExeEdge representation
of a qEdge to be executed +QG->>I: return qXEdges + +I->>I: Inferred Mode: create
templated queries + +loop Executing with Edge Manager +I->>I: while there are unexecuted qXEdges,
get next qXEdge + +I->>BEQ: BatchEdgeQueryHandler() +BEQ->>BEQ: NodesUpdateHandler(): get equivalent IDs +BEQ->>BEQ: cacheHandler(): fetch cached records + +alt if there are uncached qXEdges +BEQ->>Q2A: QEdge2APIEdgeHandler() +Q2A->>Q2A: convert qXEdges into API calls by using
metaKG to get metaEdges for qXEdge +Q2A->>BEQ: return metaXEdges +note right of BEQ: metaEdge - An edge in the metaKG
metaXEdge - A metaEdge pair with a qXEdge +BEQ->>C: query() +C->>C: make API calls in batches
and merge results +C->>BEQ: return records from APIs +end + +BEQ->>BEQ: cacheHandler(): cache result records +note right of BEQ: record - A single unit of transformed
data from a sub-query response + +BEQ->>I: return records + +I->>I: Store records/update edge manager +I->>I: Mark Edge as Executed +end + +I->>R: trapiResultsAssembler +R->>R: assemble and convert records into
final return results +R->>I: put results in bteGraph +note left of R: result - 1 item of the array in the
TRAPI response (message.results) +I->>I: bteGraph: prune not fully connected
results from graph +note right of BEQ: all files are part of query_graph_handler
except for call-apis wich is a separate module +``` + --- From 1462a714d87b4f19ee84edb7a6d174228b6395f6 Mon Sep 17 00:00:00 2001 From: Eric Zhou Date: Thu, 18 Aug 2022 09:52:05 -0700 Subject: [PATCH 2/3] feat: add color to diagram --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fcf08c7c..fb10afd4 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,9 @@ participant QG as query_graph.js participant BEQ as batch_edge_query.js participant Q2A as qedge2apiedge.js participant R as query_results.js -participant C as call-apis +participant C as call-apis module +note over I, R: query_graph_handler module I->>QG: processQueryGraph() QG->>QG: Process TRAPI Query Graph Object into
internal qEdge and qXEdge representation @@ -38,6 +39,7 @@ QG->>I: return qXEdges I->>I: Inferred Mode: create
templated queries +rect rgb(47, 71, 145) loop Executing with Edge Manager I->>I: while there are unexecuted qXEdges,
get next qXEdge @@ -45,6 +47,7 @@ I->>BEQ: BatchEdgeQueryHandler() BEQ->>BEQ: NodesUpdateHandler(): get equivalent IDs BEQ->>BEQ: cacheHandler(): fetch cached records +rect rgb(127, 44, 171) alt if there are uncached qXEdges BEQ->>Q2A: QEdge2APIEdgeHandler() Q2A->>Q2A: convert qXEdges into API calls by using
metaKG to get metaEdges for qXEdge @@ -54,6 +57,7 @@ BEQ->>C: query() C->>C: make API calls in batches
and merge results C->>BEQ: return records from APIs end +end BEQ->>BEQ: cacheHandler(): cache result records note right of BEQ: record - A single unit of transformed
data from a sub-query response @@ -63,13 +67,13 @@ BEQ->>I: return records I->>I: Store records/update edge manager I->>I: Mark Edge as Executed end +end I->>R: trapiResultsAssembler R->>R: assemble and convert records into
final return results R->>I: put results in bteGraph note left of R: result - 1 item of the array in the
TRAPI response (message.results) I->>I: bteGraph: prune not fully connected
results from graph -note right of BEQ: all files are part of query_graph_handler
except for call-apis wich is a separate module ``` From 135f05e82b9113114e042a8de9046b83da4e260d Mon Sep 17 00:00:00 2001 From: Eric Zhou Date: Mon, 22 Aug 2022 10:17:48 -0700 Subject: [PATCH 3/3] fix: remove color --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index fb10afd4..57065cee 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ QG->>I: return qXEdges I->>I: Inferred Mode: create
templated queries -rect rgb(47, 71, 145) loop Executing with Edge Manager I->>I: while there are unexecuted qXEdges,
get next qXEdge @@ -47,7 +46,6 @@ I->>BEQ: BatchEdgeQueryHandler() BEQ->>BEQ: NodesUpdateHandler(): get equivalent IDs BEQ->>BEQ: cacheHandler(): fetch cached records -rect rgb(127, 44, 171) alt if there are uncached qXEdges BEQ->>Q2A: QEdge2APIEdgeHandler() Q2A->>Q2A: convert qXEdges into API calls by using
metaKG to get metaEdges for qXEdge @@ -57,7 +55,6 @@ BEQ->>C: query() C->>C: make API calls in batches
and merge results C->>BEQ: return records from APIs end -end BEQ->>BEQ: cacheHandler(): cache result records note right of BEQ: record - A single unit of transformed
data from a sub-query response @@ -67,7 +64,6 @@ BEQ->>I: return records I->>I: Store records/update edge manager I->>I: Mark Edge as Executed end -end I->>R: trapiResultsAssembler R->>R: assemble and convert records into
final return results