From c185973dc262cfd304e39dfaeea694780fbf52f3 Mon Sep 17 00:00:00 2001 From: Conrad Date: Wed, 18 Sep 2024 15:32:28 +1000 Subject: [PATCH] fix frontend crash when gpu data is missing also remove hardcoded case for 2 gpus --- frontend/src/usage.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/frontend/src/usage.js b/frontend/src/usage.js index e17281d..176cfb8 100644 --- a/frontend/src/usage.js +++ b/frontend/src/usage.js @@ -28,27 +28,19 @@ export function getNodeUsage(jid, job, node, host) { } } - // If thif is a GPU job + // If this is a GPU job let gpuNumbers = []; - if (job.nGpus > 0) { + if (job.nGpus > 0 && node.gpus) { // Zero if unknown usage.gpu.total = 0; - // TODO: currently hardcoded to 2, - // but can make this general from the API - const nGpuMax = 2; - // If the GPU mapping is known if (Object.prototype.hasOwnProperty.call(job.gpuLayout, host)) { if (job.gpuLayout[host].length > 0) { gpuNumbers = job.gpuLayout[host]; } - // If both GPUs are used in a 2 GPU job, then mapping doesn't matter - } else if (job.nGpus === nGpuMax) { - for (let j = 0; j < nGpuMax; j += 1) { - gpuNumbers.push(j); - } } + for (let j = 0; j < gpuNumbers.length; j += 1) { const iGpu = gpuNumbers[j]; usage.gpu.total += node.gpus["gpu".concat(iGpu.toString())];