diff --git a/src/batch_edge_query.ts b/src/batch_edge_query.ts index 0d84398..734d416 100644 --- a/src/batch_edge_query.ts +++ b/src/batch_edge_query.ts @@ -2,7 +2,7 @@ import call_api from '@biothings-explorer/call-apis'; import { redisClient } from '@biothings-explorer/utils'; import QEdge2APIEdgeHandler, { APIEdge } from './qedge2apiedge'; import NodesUpdateHandler from './update_nodes'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug('bte:biothings-explorer-trapi:batch_edge_query'); import CacheHandler from './cache_handler'; import { threadId } from 'worker_threads'; diff --git a/src/cache_handler.ts b/src/cache_handler.ts index f62f3a8..e9992e2 100644 --- a/src/cache_handler.ts +++ b/src/cache_handler.ts @@ -1,5 +1,5 @@ import { redisClient } from '@biothings-explorer/utils'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug('bte:biothings-explorer-trapi:cache_handler'); import { LogEntry, StampedLog } from '@biothings-explorer/utils'; import async from 'async'; diff --git a/src/edge_manager.ts b/src/edge_manager.ts index 15d6a13..92f009f 100644 --- a/src/edge_manager.ts +++ b/src/edge_manager.ts @@ -1,7 +1,7 @@ import _ from 'lodash'; import { LogEntry, StampedLog } from '@biothings-explorer/utils'; import BTEError from './exceptions/bte_error'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug('bte:biothings-explorer-trapi:edge-manager'); import * as config from './config'; import BatchEdgeQueryHandler, { BatchEdgeQueryOptions } from './batch_edge_query'; diff --git a/src/graph/graph.ts b/src/graph/graph.ts index 5227594..718a202 100644 --- a/src/graph/graph.ts +++ b/src/graph/graph.ts @@ -1,6 +1,6 @@ import kg_edge from './kg_edge'; import kg_node from './kg_node'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; import { LogEntry, StampedLog } from '@biothings-explorer/utils'; import KGNode from './kg_node'; import KGEdge from './kg_edge'; diff --git a/src/graph/knowledge_graph.ts b/src/graph/knowledge_graph.ts index c5f2b87..5745f83 100644 --- a/src/graph/knowledge_graph.ts +++ b/src/graph/knowledge_graph.ts @@ -1,4 +1,4 @@ -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; import { TrapiAttribute, TrapiKnowledgeGraph, diff --git a/src/index.ts b/src/index.ts index c41b2d1..b98f722 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import QueryGraph from './query_graph'; import KnowledgeGraph from './graph/knowledge_graph'; import TrapiResultsAssembler from './results_assembly/query_results'; import InvalidQueryGraphError from './exceptions/invalid_query_graph_error'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug('bte:biothings-explorer-trapi:main'); import Graph from './graph/graph'; import EdgeManager from './edge_manager'; diff --git a/src/inferred_mode/inferred_mode.ts b/src/inferred_mode/inferred_mode.ts index 4828da4..1b13149 100644 --- a/src/inferred_mode/inferred_mode.ts +++ b/src/inferred_mode/inferred_mode.ts @@ -1,4 +1,4 @@ -import Debug from 'debug'; +import { Debug, withDebugContext } from "@biothings-explorer/utils" import { biolink, getUnique, @@ -648,7 +648,8 @@ export default class InferredQueryHandler { handler.setQueryGraph(queryGraph); const failedHandlerLogs: { [index: number]: StampedLog[] } = {}; try { - await timeoutPromise(handler.query(AbortSignal.timeout(this.CREATIVE_TIMEOUT)), this.CREATIVE_TIMEOUT); + const query = withDebugContext(` Template-${i + 1}`, handler.query.bind(handler)); + await timeoutPromise(query(AbortSignal.timeout(this.CREATIVE_TIMEOUT)), this.CREATIVE_TIMEOUT); } catch (error) { handler.logs.forEach((log) => { log.message = `[Template-${i + 1}]: ${log.message}`; diff --git a/src/inferred_mode/pathfinder.ts b/src/inferred_mode/pathfinder.ts index 0c04b1f..c393fca 100644 --- a/src/inferred_mode/pathfinder.ts +++ b/src/inferred_mode/pathfinder.ts @@ -13,7 +13,7 @@ import InferredQueryHandler from './inferred_mode'; import { scaled_sigmoid, inverse_scaled_sigmoid } from '../results_assembly/score'; import * as utils from '@biothings-explorer/utils'; import { LogEntry, StampedLog, Telemetry, removeBioLinkPrefix } from '@biothings-explorer/utils'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; import generateTemplates from './pf_template_generator'; import { enrichTrapiResultsWithPfocrFigures } from '../results_assembly/pfocr'; const debug = Debug('bte:biothings-explorer-trapi:pathfinder'); diff --git a/src/qedge2apiedge.ts b/src/qedge2apiedge.ts index 29e592d..67802a8 100644 --- a/src/qedge2apiedge.ts +++ b/src/qedge2apiedge.ts @@ -2,7 +2,7 @@ import _ from 'lodash'; import { LogEntry, StampedLog } from '@biothings-explorer/utils'; import * as config from './config'; const CURIE_WITH_PREFIXES = ['MONDO', 'DOID', 'UBERON', 'EFO', 'HP', 'CHEBI', 'CL', 'MGI', 'NCIT']; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; import QEdge from './query_edge'; import MetaKG from '@biothings-explorer/smartapi-kg'; import { SmartAPIKGOperationObject } from '@biothings-explorer/smartapi-kg'; diff --git a/src/query_edge.ts b/src/query_edge.ts index 2905511..7673200 100644 --- a/src/query_edge.ts +++ b/src/query_edge.ts @@ -1,5 +1,5 @@ import helper from './helper'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; import { Record, RecordNode, FrozenRecord } from '@biothings-explorer/api-response-transform'; import QNode from './query_node'; import { QNodeInfo } from './query_node'; diff --git a/src/query_graph.ts b/src/query_graph.ts index 88b9021..bab9426 100644 --- a/src/query_graph.ts +++ b/src/query_graph.ts @@ -2,7 +2,7 @@ import QEdge from './query_edge'; import InvalidQueryGraphError from './exceptions/invalid_query_graph_error'; import * as utils from '@biothings-explorer/utils'; import { LogEntry, StampedLog } from '@biothings-explorer/utils'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; import QNode from './query_node'; import { resolveSRI } from 'biomedical_id_resolver'; import _ from 'lodash'; diff --git a/src/query_node.ts b/src/query_node.ts index 01106d7..e3cd2f4 100644 --- a/src/query_node.ts +++ b/src/query_node.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-var-requires */ import _ from 'lodash'; import * as utils from '@biothings-explorer/utils'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; import InvalidQueryGraphError from './exceptions/invalid_query_graph_error'; import { SRIBioEntity } from 'biomedical_id_resolver'; const debug = Debug('bte:biothings-explorer-trapi:QNode'); diff --git a/src/results_assembly/pfocr.ts b/src/results_assembly/pfocr.ts index a17c84a..83a6691 100644 --- a/src/results_assembly/pfocr.ts +++ b/src/results_assembly/pfocr.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; const debug = Debug('bte:biothings-explorer-trapi:pfocr'); import _ from 'lodash'; import { LogEntry, StampedLog, intersection, biolink, toArray, removeBioLinkPrefix } from '@biothings-explorer/utils'; diff --git a/src/results_assembly/query_results.ts b/src/results_assembly/query_results.ts index 9c44491..94500ba 100644 --- a/src/results_assembly/query_results.ts +++ b/src/results_assembly/query_results.ts @@ -1,6 +1,6 @@ import { LogEntry, StampedLog } from '@biothings-explorer/utils'; import { TrapiResult } from '@biothings-explorer/types'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; import { zip } from 'lodash'; const debug = Debug('bte:biothings-explorer-trapi:QueryResult'); import { getScores, calculateScore, ScoreCombos } from './score'; diff --git a/src/results_assembly/score.ts b/src/results_assembly/score.ts index d23004c..ca36040 100644 --- a/src/results_assembly/score.ts +++ b/src/results_assembly/score.ts @@ -1,4 +1,4 @@ -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; import axios from 'axios'; const debug = Debug('bte:biothings-explorer-trapi:score'); import os from 'os'; diff --git a/src/update_nodes.ts b/src/update_nodes.ts index 2b41d54..efcaf5a 100644 --- a/src/update_nodes.ts +++ b/src/update_nodes.ts @@ -1,5 +1,5 @@ import { resolveSRI } from 'biomedical_id_resolver'; -import Debug from 'debug'; +import { Debug } from "@biothings-explorer/utils"; import { ResolverInput, SRIResolverOutput } from 'biomedical_id_resolver'; import { Record } from '@biothings-explorer/api-response-transform'; import QEdge from './query_edge';