Skip to content

Commit

Permalink
add: path get thread
Browse files Browse the repository at this point in the history
  • Loading branch information
mosoriob committed Sep 5, 2024
1 parent 9ea863e commit be57e33
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 44 deletions.
43 changes: 43 additions & 0 deletions src/api/api-v1/paths/threads/{id}.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// ./api/api-v1/paths/threads.ts

export default function (threadsService: any) {
const operations = {
GET
};

//threads/:id
async function GET(req: any, res: any, next: any) {
try {
const response = await threadsService.getThread(req.params.id);
if (response === undefined) res.status(404).send();
else res.status(200).send(response);
} catch (error) {
res.status(500).send(error);
}
}

GET.apiDoc = {
summary: "Get modeling thread in MINT.",
operationId: "getThread",
parameters: [
{
in: "path",
name: "id",
required: true,
schema: {
type: "string"
}
}
],
responses: {
"200": {
description: "Successful response"
},
default: {
description: "An error occurred"
}
}
};

return operations;
}
13 changes: 12 additions & 1 deletion src/api/api-v1/services/threadsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
getRegionDetails,
getTask,
getThread,
getThreadV2,
getTotalConfigurations,
setThreadData,
setThreadModels,
Expand All @@ -41,6 +42,12 @@ function flatten(array) {
}

const threadsService = {
async getThread(thread_id: string) {
const mint_prefs = await fetchMintConfig();
KeycloakAdapter.signIn(mint_prefs.graphql.username, mint_prefs.graphql.password);
return await getThreadV2(thread_id);
},

async createThread(desc: any) {
const mint_prefs = await fetchMintConfig();
KeycloakAdapter.signIn(mint_prefs.graphql.username, mint_prefs.graphql.password);
Expand Down Expand Up @@ -191,7 +198,11 @@ const threadsService = {
}
}
// Get total number of configs to run
const totalconfigs = getTotalConfigurations(model, model_ensembles[model.id].bindings, data);
const totalconfigs = getTotalConfigurations(
model,
model_ensembles[model.id].bindings,
data
);
execution_summary[model.id] = {
total_runs: totalconfigs,
submitted_runs: 0,
Expand Down
25 changes: 25 additions & 0 deletions src/classes/graphql/graphql_functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,31 @@ export const getThread = async (threadid: string): Promise<Thread> => {
});
};

export const getThreadV2 = async (threadId: string): Promise<Thread> => {
try {
const APOLLO_CLIENT = GraphQL.instance(KeycloakAdapter.getUser());
const response = await APOLLO_CLIENT.query({
query: getThreadGQL,
fetchPolicy: "no-cache",
variables: {
id: threadId
}
});

if (!response || (response.errors && response.errors.length > 0)) {
throw new Error(response.errors.join(", "));
} else {
const thread = response.data.thread_by_pk;
if (thread) {
return threadFromGQL(thread);
}
}
} catch (error) {
console.log(error);
throw error;
}
};

export const getModel = async (modelid: string): Promise<Model> => {
const APOLLO_CLIENT = GraphQL.instance(KeycloakAdapter.getUser());
return APOLLO_CLIENT.query({
Expand Down
86 changes: 43 additions & 43 deletions src/config/config.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
{
"data_catalog_api": "http://localhost:5000",
"data_catalog_type": "CKAN",
"data_catalog_key": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJaUGd3Snk1YUxRbW9keTBnd1R0SkNDMG5QeU5vMjg3QnRCd0J4WVVpWHFBIiwiaWF0IjoxNzAxNTMyNzE1fQ.yX8S6H1MD7eZYoDTX6Adybv3V5ezrgz-Y2zNOqjhEXo",
"data_catalog_extra": {
"owner_organization_id": "21033e7d-484d-4974-9340-8c5755242c1f",
"owner_provenance_id": "9ef60317-5da5-4050-8bbc-7d6826fee49f"
},
"data_server_type": "Local",
"data_server_extra": {
"region": "ap-south-1",
"bucket": "mintdata",
"access_key": "CHANGEME",
"secret_access_key": "CHANGEME"
},
"model_catalog_api": "https://api.models.dev.mint.isi.edu/v1.8.0",
"data_catalog_api": "http://localhost:5000",
"data_catalog_type": "CKAN",
"data_catalog_key": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJaUGd3Snk1YUxRbW9keTBnd1R0SkNDMG5QeU5vMjg3QnRCd0J4WVVpWHFBIiwiaWF0IjoxNzAxNTMyNzE1fQ.yX8S6H1MD7eZYoDTX6Adybv3V5ezrgz-Y2zNOqjhEXo",
"data_catalog_extra": {
"owner_organization_id": "21033e7d-484d-4974-9340-8c5755242c1f",
"owner_provenance_id": "9ef60317-5da5-4050-8bbc-7d6826fee49f"
},
"data_server_type": "Local",
"data_server_extra": {
"region": "ap-south-1",
"bucket": "mintdata",
"access_key": "CHANGEME",
"secret_access_key": "CHANGEME"
},
"model_catalog_api": "https://api.models.dev.mint.isi.edu/v1.8.0",

"ensemble_manager_api": "http://localhost:3000/v1",
"graphql": {
"endpoint": "localhost:30003/v1/graphql",
"enable_ssl": false,
"use_secret": true,
"secret": "CHANGEME"
},
"execution_engine": "localex",
"localex": {
"codedir": "/Users/varun/mintproject/data/code",
"datadir": "/Users/varun/mintproject/data/data",
"tempdir": "/Users/varun/mintproject/data/temp",
"logdir": "/Users/varun/mintproject/data/logs",
"dataurl": "file:///Users/varun/mintproject/data/data",
"logurl": "file:///Users/varun/mintproject/data/logs",
"parallelism": 2
},
"kubernetes": {
"use": true,
"namespace": "mint",
"cpu_limit": "800m",
"memory_limit": "2048Mi"
},
"auth_server": "https://auth.mint.isi.edu/",
"auth_realm": "production",
"auth_client_id": "mint-ui",
"visualization_url": "",
"ingestion_api": ""
"ensemble_manager_api": "http://localhost:3000/v1",
"graphql": {
"endpoint": "graphql.mint.local/v1/graphql",
"enable_ssl": false,
"use_secret": true,
"secret": "CHANGEME"
},
"execution_engine": "localex",
"localex": {
"codedir": "/Users/varun/mintproject/data/code",
"datadir": "/Users/varun/mintproject/data/data",
"tempdir": "/Users/varun/mintproject/data/temp",
"logdir": "/Users/varun/mintproject/data/logs",
"dataurl": "file:///Users/varun/mintproject/data/data",
"logurl": "file:///Users/varun/mintproject/data/logs",
"parallelism": 2
},
"kubernetes": {
"use": true,
"namespace": "mint",
"cpu_limit": "800m",
"memory_limit": "2048Mi"
},
"auth_server": "https://auth.mint.isi.edu/",
"auth_realm": "production",
"auth_client_id": "mint-ui",
"visualization_url": "",
"ingestion_api": ""
}

0 comments on commit be57e33

Please sign in to comment.