From edadf526c3127a1ee045f9280984eed69742e2ba Mon Sep 17 00:00:00 2001 From: rjawesome Date: Fri, 1 Nov 2024 12:03:13 -0700 Subject: [PATCH] add template to creative debug --- src/batch_edge_query.ts | 2 +- src/cache_handler.ts | 2 +- src/edge_manager.ts | 2 +- src/graph/graph.ts | 2 +- src/graph/knowledge_graph.ts | 2 +- src/index.ts | 2 +- src/inferred_mode/inferred_mode.ts | 5 +++-- src/inferred_mode/pathfinder.ts | 2 +- src/qedge2apiedge.ts | 2 +- src/query_edge.ts | 2 +- src/query_graph.ts | 2 +- src/query_node.ts | 2 +- src/results_assembly/pfocr.ts | 2 +- src/results_assembly/query_results.ts | 2 +- src/results_assembly/score.ts | 2 +- src/update_nodes.ts | 2 +- 16 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/batch_edge_query.ts b/src/batch_edge_query.ts index 0d843985..734d4165 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 f62f3a84..e9992e2d 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 15d6a130..92f009fc 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 5227594d..718a2023 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 c5f2b870..5745f832 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 c41b2d18..b98f7224 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 4828da46..1b13149d 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 0c04b1fd..c393fcab 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 29e592da..67802a8b 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 29055119..76732008 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 88b90210..bab94268 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 01106d7a..e3cd2f49 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 a17c84a5..83a66916 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 9c444916..94500bae 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 d23004c6..ca360409 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 2b41d549..efcaf5ad 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';