From df654897484fdd3fbc1902f35595501f032b772e Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Tue, 12 Dec 2023 12:11:20 -0500 Subject: [PATCH 1/2] feat: use instance-appropriate nodenorm --- src/sri.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/sri.ts b/src/sri.ts index 77560a9..8388164 100644 --- a/src/sri.ts +++ b/src/sri.ts @@ -9,13 +9,17 @@ const debug = Debug('bte:biomedical-id-resolver:SRI'); /** sets up request retry policy (weird typescript b/c old axios version) */ // @ts-ignore -axiosRetry(axios, { retries: 3, retryDelay: axiosRetry.exponentialDelay, retryCondition: (err) => { +axiosRetry(axios, { + retries: 3, + retryDelay: axiosRetry.exponentialDelay, + retryCondition: (err) => { return axiosRetry.isNetworkOrIdempotentRequestError(err) || err.response?.status >= 500; -} }) + }, +}); /** convert object of arrays into array of unique IDs */ function combineInputs(userInput: ResolverInput): string[] { - const result = Object.keys(userInput).reduce(function (r, k) { + const result = Object.keys(userInput).reduce(function(r, k) { return r.concat(userInput[k]); }, []); return [...new Set(result)]; @@ -26,13 +30,19 @@ function combineInputs(userInput: ResolverInput): string[] { * handles querying and batching of inputs */ async function query(api_input: string[]) { - const url = 'https://nodenorm.transltr.io/get_normalized_nodes'; + const url = { + dev: 'https://nodenormalization-sri.renci.org/get_normalized_nodes', + ci: 'https://nodenorm.ci.transltr.io/1.3/get_normalized_nodes', + test: 'https://nodenorm.test.transltr.io/1.3/get_normalized_nodes', + prod: 'https://nodenorm.transltr.io/1.3/get_normalized_nodes', + }[process.env.NODE_ENV ?? 'prod']; const chunked_input = _.chunk(api_input, 1000); try { - const userAgent = `BTE/${process.env.NODE_ENV === 'production' ? 'prod' : 'dev'} Node/${process.version} ${ - process.platform - }`; + const userAgent = [ + `BTE/${process.env.NODE_ENV === 'production' ? 'prod' : 'dev'}`, + `Node/${process.version} ${process.platform}`, + ].join(' '); const axios_queries = chunked_input.map((input) => { return axios.post(url, { curies: input }, { headers: { 'User-Agent': userAgent } }); }); From 2d74008e761f7e087fe50350c00077cd0a7c9dcc Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Tue, 12 Dec 2023 12:28:03 -0500 Subject: [PATCH 2/2] fix: use instance_env --- src/sri.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sri.ts b/src/sri.ts index 8388164..54fab86 100644 --- a/src/sri.ts +++ b/src/sri.ts @@ -35,7 +35,7 @@ async function query(api_input: string[]) { ci: 'https://nodenorm.ci.transltr.io/1.3/get_normalized_nodes', test: 'https://nodenorm.test.transltr.io/1.3/get_normalized_nodes', prod: 'https://nodenorm.transltr.io/1.3/get_normalized_nodes', - }[process.env.NODE_ENV ?? 'prod']; + }[process.env.INSTANCE_ENV ?? 'prod']; const chunked_input = _.chunk(api_input, 1000); try {