Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Read MetaKG from global var if exists - v1/meta_knowledge_graph_v1" #55

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Loading