Skip to content

Commit

Permalink
fix: add debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
ericz1803 committed Nov 1, 2021
1 parent 7964c07 commit 84421b9
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/sri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function combineInputs(userInput: ResolverInput): string[] {
async function query(api_input: string[]) {
let url = 'https://nodenormalization-sri.renci.org/1.2/get_normalized_nodes';

let chunked_input = _.chunk(api_input, 10000);
let chunked_input = _.chunk(api_input, 1500);

let axios_queries = chunked_input.map((input) => {
return axios.post(url, {curies: input});
Expand Down Expand Up @@ -102,6 +102,7 @@ function ResolvableEntry(SRIEntry): SRIBioEntity {

//transform output from SRI into original resolver shape
function transformResults(results): SRIResolverOutput {
debug(`Starting transformResults`);
Object.keys(results).forEach((key) => {
let entry = results[key];
if (entry === null) { //handle unresolvable entities
Expand Down Expand Up @@ -149,13 +150,29 @@ function mapInputSemanticTypes(originalInput: ResolverInput, result: SRIResolver
}

export async function _resolveSRI(userInput: ResolverInput): Promise<SRIResolverOutput> {
let startTime = performance.now();

let uniqueInputIDs = combineInputs(userInput);

let endTime = performance.now();

debug(`Querying SRI for ${uniqueInputIDs.length} IDs. Took ${endTime - startTime}ms to calculate unique ids.`)

let queryResults = await query(uniqueInputIDs);

let endTime1 = performance.now();

debug(`Querying SRI for ${uniqueInputIDs.length} IDs took ${endTime1 - endTime} milliseconds.`);

queryResults = transformResults(queryResults);

debug(`Finished transformResults.`);

queryResults = mapInputSemanticTypes(userInput, queryResults);

let endTime2 = performance.now();

debug(`Took ${endTime2 - endTime}ms to process results. ${endTime2 - startTime}ms total.`);

return queryResults;
}

0 comments on commit 84421b9

Please sign in to comment.