@@ -222,6 +222,14 @@ def _job_state_name(state: int) -> str:
222222 return div.innerHTML;
223223 }
224224
225+ function formatBytes(bytes) {
226+ if (bytes === 0) return '0 B';
227+ const k = 1024;
228+ const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
229+ const i = Math.floor(Math.log(bytes) / Math.log(k));
230+ return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
231+ }
232+
225233 async function refresh() {
226234 try {
227235 const [stats, actions, workers, jobs, endpoints] = await Promise.all([
@@ -262,7 +270,8 @@ def _job_state_name(state: int) -> str:
262270 ? `<a href="http://${escapeHtml(w.address)}/" class="worker-link" target="_blank">${wid}</a>`
263271 : wid;
264272 const cpu = w.resources ? w.resources.cpu : '-';
265- const memory = w.resources ? (w.resources.memory || '-') : '-';
273+ const memBytes = w.resources ? (w.resources.memory_bytes || 0) : 0;
274+ const memory = memBytes ? formatBytes(memBytes) : '-';
266275 return `<tr>
267276 <td>${workerLink}</td>
268277 <td class="${healthClass}">${w.healthy ? 'Yes' : 'No'}</td>
@@ -280,8 +289,9 @@ def _job_state_name(state: int) -> str:
280289 const jobsHtml = jobs.map(j => {
281290 const jid = escapeHtml(j.job_id);
282291 const jobLink = `<a href="/job/${jid}" class="job-link">${jid.slice(0,8)}...</a>`;
292+ const jobMemBytes = j.resources ? (j.resources.memory_bytes || 0) : 0;
283293 const resources = j.resources
284- ? `${j.resources.cpu} CPU, ${j.resources.memory || '-'}` : '-';
294+ ? `${j.resources.cpu} CPU, ${jobMemBytes ? formatBytes(jobMemBytes) : '-'}` : '-';
285295 return `<tr>
286296 <td>${jobLink}</td>
287297 <td>${escapeHtml(j.name)}</td>
@@ -778,8 +788,8 @@ def _api_workers(self, _request: Request) -> JSONResponse:
778788 "consecutive_failures" : w .consecutive_failures ,
779789 "last_heartbeat_ms" : w .last_heartbeat_ms ,
780790 "resources" : {
781- "cpu" : w .resources . cpu if w . resources else 0 ,
782- "memory " : w .resources . memory if w . resources else "" ,
791+ "cpu" : w .metadata . cpu_count ,
792+ "memory_bytes " : w .metadata . memory_bytes ,
783793 },
784794 }
785795 for w in workers
@@ -805,7 +815,7 @@ def _api_jobs(self, _request: Request) -> JSONResponse:
805815 "preemption_count" : j .preemption_count ,
806816 "resources" : {
807817 "cpu" : j .request .resources .cpu if j .request .resources else 0 ,
808- "memory " : j .request .resources .memory if j .request .resources else "" ,
818+ "memory_bytes " : j .request .resources .memory_bytes if j .request .resources else 0 ,
809819 },
810820 }
811821 for j in jobs
0 commit comments