Skip to content

Commit

Permalink
Changes in JSON structure.
Browse files Browse the repository at this point in the history
Code changes according to the changes in JSON structure.
  • Loading branch information
aratikakadiya committed Nov 7, 2024
1 parent 572c662 commit a5f655a
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 98 deletions.
178 changes: 92 additions & 86 deletions deployment/helm/skaha/skaha-config/k8s-resources.json
Original file line number Diff line number Diff line change
@@ -1,88 +1,94 @@
{
"cores-default-request": 1,
"cores-default-limit": 16,
"cores-default": 1,
"cores-default-headless": 1,
"cores-options": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16
],
"mem-gb-default-request": 4,
"mem-gb-default-limit": 192,
"mem-gb-default": 2,
"mem-gb-default-headless": 4,
"mem-gb-options": [
1,
2,
4,
6,
8,
10,
12,
14,
16,
20,
24,
26,
28,
30,
32,
36,
40,
44,
48,
56,
64,
80,
92,
112,
128,
140,
170,
192
],
"gpus-options": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28
]
"cores": {
"default": 1,
"default-request": 1,
"default-limit": 16,
"default-headless": 1,
"options": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16
]
},
"memory": {
"default-request-gb": 4,
"default-limit-gb": 192,
"default-gb": 2,
"default-headless-gb": 4,
"options-gb": [
1,
2,
4,
6,
8,
10,
12,
14,
16,
20,
24,
26,
28,
30,
32,
36,
40,
44,
48,
56,
64,
80,
92,
112,
128,
140,
170,
192
]
},
"gpus": {
"options": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,24 @@ public ResourceContexts() {
JsonObject jsonObject = jsonElement.getAsJsonObject();

// Extract fields into variables
defaultRequestCores= jsonObject.get("cores-default-request").getAsInt();
defaultLimitCores = jsonObject.get("cores-default-limit").getAsInt();
defaultCores = jsonObject.get("cores-default").getAsInt();
defaultCoresHeadless = jsonObject.get("cores-default-headless").getAsInt();
defaultRequestRAM = jsonObject.get("mem-gb-default-request").getAsInt();
defaultLimitRAM = jsonObject.get("mem-gb-default-limit").getAsInt();
defaultRAM = jsonObject.get("mem-gb-default").getAsInt();
defaultRAMHeadless = jsonObject.get("mem-gb-default-headless").getAsInt();

JsonArray coresOptions = jsonObject.getAsJsonArray("cores-options");
JsonObject cores = jsonObject.getAsJsonObject("cores");
defaultRequestCores= cores.get("default-request").getAsInt();
defaultLimitCores = cores.get("default-limit").getAsInt();
defaultCores = cores.get("default").getAsInt();
defaultCoresHeadless = cores.get("default-headless").getAsInt();
JsonArray coresOptions = cores.getAsJsonArray("options");
coresOptions.asList().forEach(coreOption->availableCores.add(coreOption.getAsInt()));

JsonArray ramOptions = jsonObject.getAsJsonArray("mem-gb-options");
JsonObject memory = jsonObject.getAsJsonObject("memory");
defaultRequestRAM = memory.get("default-request-gb").getAsInt();
defaultLimitRAM = memory.get("default-limit-gb").getAsInt();
defaultRAM = memory.get("default-gb").getAsInt();
defaultRAMHeadless = memory.get("default-headless-gb").getAsInt();
JsonArray ramOptions = memory.getAsJsonArray("options-gb");
ramOptions.asList().forEach(ramOption -> availableRAM.add(ramOption.getAsInt()));

JsonArray gpuOptions = jsonObject.getAsJsonArray("gpus-option");
JsonObject gpus = jsonObject.getAsJsonObject("gpus");
JsonArray gpuOptions = gpus.getAsJsonArray("options");
gpuOptions.asList().forEach(gpuOption -> availableGPUs.add(gpuOption.getAsInt()));
} catch (Exception e) {
log.error(e);
Expand Down

0 comments on commit a5f655a

Please sign in to comment.