MCPcopy
hub / github.com/SwanHubX/SwanLab / _format_cpu_memory

Function _format_cpu_memory

swanlab/cli/ping/__init__.py:317–340  ·  view source on GitHub ↗
(hardware: HardwareSnapshot)

Source from the content-addressed store, hash-verified

315
316
317def _format_cpu_memory(hardware: HardwareSnapshot) -> list[str]:
318 lines = []
319 if _has_field(hardware, "cpu"):
320 cpu = hardware.cpu
321 brand = _optional_string(cpu, "brand")
322 lines.append(_result_line(True, "CPU", brand) if brand else _missing_line("CPU"))
323 core_parts = []
324 if _has_field(cpu, "logical_count"):
325 core_parts.append(f"{cpu.logical_count} logical")
326 if _has_field(cpu, "physical_count"):
327 core_parts.append(f"{cpu.physical_count} physical")
328 lines.append(
329 _result_line(True, "CPU Cores", " / ".join(core_parts)) if core_parts else _missing_line("CPU Cores")
330 )
331 else:
332 lines.append(_missing_line("CPU", "Not collected"))
333 lines.append(_missing_line("CPU Cores", "Not collected"))
334
335 if _has_field(hardware, "memory"):
336 memory = _format_memory(hardware.memory, "total", "total_unit")
337 lines.append(_result_line(True, "Memory", memory) if memory else _missing_line("Memory"))
338 else:
339 lines.append(_missing_line("Memory", "Not collected"))
340 return lines
341
342
343def _format_accelerators(hardware: HardwareSnapshot) -> list[str]:

Callers 1

_format_hardwareFunction · 0.85

Calls 6

_has_fieldFunction · 0.85
_optional_stringFunction · 0.85
_result_lineFunction · 0.85
_missing_lineFunction · 0.85
_format_memoryFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…