diff --git a/package.json b/package.json index 6426eca..7b51798 100644 --- a/package.json +++ b/package.json @@ -57,12 +57,12 @@ "@biothings-explorer/call-apis": "workspace:../call-apis", "@biothings-explorer/node-expansion": "workspace:../node-expansion", "@biothings-explorer/smartapi-kg": "workspace:../smartapi-kg", - "@biothings-explorer/utils": "workspace:../utils", "@biothings-explorer/types": "workspace:../types", - "biolink-model": "workspace:../biolink-model", - "biomedical_id_resolver": "workspace:../biomedical_id_resolver", + "@biothings-explorer/utils": "workspace:../utils", "@sentry/node": "^7.74.1", "async": "^3.2.4", + "biolink-model": "workspace:../biolink-model", + "biomedical_id_resolver": "workspace:../biomedical_id_resolver", "chi-square-p-value": "^1.0.5", "debug": "^4.3.4", "ioredis": "^5.3.2", diff --git a/src/index.ts b/src/index.ts index 8251a36..ac23cf3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,7 +10,7 @@ import Graph from './graph/graph'; import EdgeManager from './edge_manager'; import _ from 'lodash'; import QEdge2APIEdgeHandler from './qedge2apiedge'; -import { LogEntry, StampedLog } from '@biothings-explorer/utils'; +import { lockWithActionAsync, LogEntry, StampedLog } from '@biothings-explorer/utils'; import { promises as fs } from 'fs'; import { getDescendants } from '@biothings-explorer/node-expansion'; import { resolveSRI, SRINodeNormFailure } from 'biomedical_id_resolver'; @@ -81,8 +81,11 @@ export default class TRAPIQueryHandler { if (this.options.smartapi) { smartapiRegistry = this.options.smartapi; } else { - const file = await fs.readFile(this.path, 'utf-8'); - smartapiRegistry = JSON.parse(file); + smartapiRegistry = await lockWithActionAsync(this.path, async () => { + const file = await fs.readFile(this.path, 'utf-8'); + const hits = JSON.parse(file); + return hits; + }, debug); } const smartapiIds: string[] = []; @@ -722,12 +725,7 @@ export default class TRAPIQueryHandler { return; } debug('MetaKG successfully loaded!'); - const filteredOps = metaKG.ops.filter(op => - op.association.qualifiers && - Object.values(op.association.qualifiers).some(value => Array.isArray(value)) - ) span1?.finish(); - // metaKG.ops = filteredOps; if (global.missingAPIs) { this.logs.push(