Skip to content

Commit

Permalink
Merge pull request #55 from biothings/revert-38-fix-851-bte
Browse files Browse the repository at this point in the history
Revert "Read MetaKG from global var if exists - `v1/meta_knowledge_graph_v1`"
  • Loading branch information
tokebe authored Nov 7, 2024
2 parents ec5841d + 50fdc95 commit d229d85
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 27 deletions.
2 changes: 1 addition & 1 deletion data/predicates.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/smartapi_specs.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ export const tasks: TaskByRoute = {
asyncquery_v1: (taskInfo: TaskInfo) => V1AsyncQuery.task(taskInfo),
asyncquery_v1_by_api: (taskInfo: TaskInfo) => V1AsyncQueryByAPI.task(taskInfo),
asyncquery_v1_by_team: (taskInfo: TaskInfo) => V1AsyncQueryByTeam.task(taskInfo),
// load MetaKG from global
meta_knowledge_graph_v1: (taskInfo: TaskInfo) => V1MetaKG.task(taskInfo),
// Not threaded due to being lightweight/speed being higher priority
// performance: (taskInfo: TaskInfo) => Performance.task(taskInfo),
// metakg: (taskInfo: TaskInfo) => MetaKG.task(taskInfo),
// meta_knowledge_graph_v1: (taskInfo: TaskInfo) => V1MetaKG.task(taskInfo),
// meta_knowledge_graph_v1_by_api: (taskInfo: TaskInfo) => V1MetaKGByAPI.task(taskInfo),
// meta_knowledge_graph_v1_by_team: (taskInfo: TaskInfo) => V1MetaKGByTeam.task(taskInfo),
};
26 changes: 3 additions & 23 deletions src/routes/v1/meta_knowledge_graph_v1.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import path from "path";
import { TaskInfo } from "@biothings-explorer/types";
import handler from "../../controllers/meta_knowledge_graph";
import * as utils from "../../utils/common";
import { runTask, taskResponse, taskError } from "../../controllers/threading/threadHandler";
import { Express, NextFunction, Request, Response, RequestHandler } from "express";

class MetaKG {
Expand All @@ -11,33 +8,16 @@ class MetaKG {
.route("/v1/meta_knowledge_graph")
.get((async (_req: Request, res: Response, next: NextFunction) => {
try {
const response = await runTask(_req, res, path.parse(__filename).name);
const metaKGHandler = new handler(undefined);
const kg = await metaKGHandler.getKG();
res.setHeader("Content-Type", "application/json");
res.end(JSON.stringify(response));
res.end(JSON.stringify(kg));
} catch (error) {
next(error);
}
}) as RequestHandler)
.all(utils.methodNotAllowed);
}

async task(taskInfo: TaskInfo) {
try {
let kg = undefined;

// read metakg from files if not globally defined
if(!taskInfo.data.options.metakg) {
const metaKGHandler = new handler(undefined);
kg = await metaKGHandler.getKG();
} else {
kg = taskInfo.data.options.metakg;
}
// response.logs = utils.filterForLogLevel(response.logs, options.logLevel);
return taskResponse(kg);
} catch (error) {
taskError(error as Error);
}
}
}

export default new MetaKG();

0 comments on commit d229d85

Please sign in to comment.