Skip to content

Commit

Permalink
add: /threads/:id (#36)
Browse files Browse the repository at this point in the history
* fix: disabled update using ci

* add: path get thread
  • Loading branch information
mosoriob authored Sep 5, 2024
1 parent 58411fd commit c35f1f4
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 138 deletions.
188 changes: 94 additions & 94 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,97 +83,97 @@ jobs:
with:
sarif_file: "trivy-results.sarif"

update:
needs: build
runs-on: ubuntu-latest
steps:
- name: Create environment variable with the commit id
run: |
echo "DOCKER_TAG=${GITHUB_SHA}" >> $GITHUB_ENV
- name: Expose the commit id
id: exposeValue
run: |
echo "::set-output name=docker_tag::${{ env.DOCKER_TAG }}"
- name: Checkout MINT Instances Repository
uses: actions/checkout@v3
with:
repository: mintproject/mint-instances
path: infrastructure
token: ${{ secrets.MINT_INSTANCES }}
ref: master

- name: Checkout MINT Chart Repository
uses: actions/checkout@v3
if: github.ref == 'refs/heads/master'
with:
repository: mintproject/mint
path: mint-chart
token: ${{ secrets.MINT_INSTANCES }}
ref: main

- name: Update MINT ISI master
uses: fjogeleit/yaml-update-action@main
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
valueFile: isi/values.yaml
propertyPath: "MINT.components.ensemble_manager.image.tag"
value: ${{ env.DOCKER_TAG }}
message: "Update ensemble_manager"
repository: mintproject/mint-instances
workDir: infrastructure
branch: master
token: ${{ secrets.MINT_INSTANCES }}

- name: Update MINT ISI WIFIRE
uses: fjogeleit/yaml-update-action@main
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
valueFile: wifire/values.yaml
propertyPath: "MINT.components.ensemble_manager.image.tag"
value: ${{ env.DOCKER_TAG }}
message: "Update ensemble_manager"
repository: mintproject/mint-instances
workDir: infrastructure
branch: master
token: ${{ secrets.MINT_INSTANCES }}

- name: Update MINT TACC
uses: fjogeleit/yaml-update-action@main
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
valueFile: tacc/values.yaml
propertyPath: "MINT.components.ensemble_manager.image.tag"
value: ${{ env.DOCKER_TAG }}
message: "Update ensemble_manager"
repository: mintproject/mint-instances
workDir: infrastructure
branch: master
token: ${{ secrets.MINT_INSTANCES }}

- name: Update MINT ISI dev
uses: fjogeleit/yaml-update-action@main
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
with:
valueFile: isi-dev/values.yaml
propertyPath: "MINT.components.ensemble_manager.image.tag"
value: ${{ env.DOCKER_TAG }}
message: "Update ensemble_manager"
repository: mintproject/mint-instances
workDir: infrastructure
branch: master
token: ${{ secrets.MINT_INSTANCES }}

- name: Update helm charts
uses: fjogeleit/yaml-update-action@main
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
valueFile: helm/values.yaml
propertyPath: "components.ensemble_manager.image.tag"
value: ${{ env.DOCKER_TAG }}
message: "Update ensemble_manager"
repository: mintproject/mint
workDir: mint-chart/
branch: main
token: ${{ secrets.MINT_INSTANCES }}
# update:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Create environment variable with the commit id
# run: |
# echo "DOCKER_TAG=${GITHUB_SHA}" >> $GITHUB_ENV

# - name: Expose the commit id
# id: exposeValue
# run: |
# echo "::set-output name=docker_tag::${{ env.DOCKER_TAG }}"

# - name: Checkout MINT Instances Repository
# uses: actions/checkout@v3
# with:
# repository: mintproject/mint-instances
# path: infrastructure
# token: ${{ secrets.MINT_INSTANCES }}
# ref: master

# - name: Checkout MINT Chart Repository
# uses: actions/checkout@v3
# if: github.ref == 'refs/heads/master'
# with:
# repository: mintproject/mint
# path: mint-chart
# token: ${{ secrets.MINT_INSTANCES }}
# ref: main

# - name: Update MINT ISI master
# uses: fjogeleit/yaml-update-action@main
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# with:
# valueFile: isi/values.yaml
# propertyPath: "MINT.components.ensemble_manager.image.tag"
# value: ${{ env.DOCKER_TAG }}
# message: "Update ensemble_manager"
# repository: mintproject/mint-instances
# workDir: infrastructure
# branch: master
# token: ${{ secrets.MINT_INSTANCES }}

# - name: Update MINT ISI WIFIRE
# uses: fjogeleit/yaml-update-action@main
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# with:
# valueFile: wifire/values.yaml
# propertyPath: "MINT.components.ensemble_manager.image.tag"
# value: ${{ env.DOCKER_TAG }}
# message: "Update ensemble_manager"
# repository: mintproject/mint-instances
# workDir: infrastructure
# branch: master
# token: ${{ secrets.MINT_INSTANCES }}

# - name: Update MINT TACC
# uses: fjogeleit/yaml-update-action@main
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# with:
# valueFile: tacc/values.yaml
# propertyPath: "MINT.components.ensemble_manager.image.tag"
# value: ${{ env.DOCKER_TAG }}
# message: "Update ensemble_manager"
# repository: mintproject/mint-instances
# workDir: infrastructure
# branch: master
# token: ${{ secrets.MINT_INSTANCES }}

# - name: Update MINT ISI dev
# uses: fjogeleit/yaml-update-action@main
# if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
# with:
# valueFile: isi-dev/values.yaml
# propertyPath: "MINT.components.ensemble_manager.image.tag"
# value: ${{ env.DOCKER_TAG }}
# message: "Update ensemble_manager"
# repository: mintproject/mint-instances
# workDir: infrastructure
# branch: master
# token: ${{ secrets.MINT_INSTANCES }}

# - name: Update helm charts
# uses: fjogeleit/yaml-update-action@main
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# with:
# valueFile: helm/values.yaml
# propertyPath: "components.ensemble_manager.image.tag"
# value: ${{ env.DOCKER_TAG }}
# message: "Update ensemble_manager"
# repository: mintproject/mint
# workDir: mint-chart/
# branch: main
# token: ${{ secrets.MINT_INSTANCES }}
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 c35f1f4

Please sign in to comment.