Showcase: DRA GPU status controller across languages - #1
Conversation
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
| ) | ||
|
|
||
| // ErrNodeNotFound is returned when a node has no inventory yet. | ||
| var ErrNodeNotFound = errors.New("node not found") |
There was a problem hiding this comment.
Good call extracting a sentinel error — now callers can errors.Is(err, ErrNodeNotFound) instead of string-matching.
| if d.Shared { | ||
| return "shared", nil | ||
| } | ||
| return "allocated", nil | ||
| } |
There was a problem hiding this comment.
This shared-vs-allocated branch reads cleanly. Consider a small table test covering both statuses.
| name: str | ||
| driver: str | ||
| ready: bool = False | ||
| devices: list[str] = field(default_factory=list) |
There was a problem hiding this comment.
Prefer an immutable default so the dataclass instances don't share state:
| devices: list[str] = field(default_factory=list) | |
| devices: tuple[str, ...] = () |
| export function DeviceList(props: { devices: Device[] }) { | ||
| const [filter, setFilter] = createSignal(""); | ||
| const shown = () => | ||
| props.devices.filter((d) => d.uuid.includes(filter())); |
There was a problem hiding this comment.
Nice — the filter reads well. includes is case-sensitive; want to lowercase both sides?
|
|
||
| // Count returns how many devices a node exposes. | ||
| func (c *StatusController) Count(node string) int { | ||
| return len(c.nodes[node]) |
There was a problem hiding this comment.
Should Count guard against a nil map, or is the zero value fine here?
There was a problem hiding this comment.
Zero value is fine — len(nil map) is 0 in Go, so no guard needed.
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
| let memoryUsed: UInt64 | ||
|
|
||
| var isSaturated: Bool { | ||
| utilization > 0.9 |
There was a problem hiding this comment.
Is 0.9 the right saturation threshold for MIG-sliced GPUs? Might be worth a named constant.
2540a7f to
c5df26d
Compare
Demo pull request for patchtree screenshots — a deliberately varied diff so the extension has everything to render.
What's here:
gpu.go(Go),server.py(Python),config.yaml(YAML)ui.tsx(TypeScript/JSX)old_helper.rs→helper.rs(Rust)legacy.rb(Ruby)go.sumlogo.pngmetrics.swift,Dockerfile, andqueries— an extensionless file auto-detected as SQLOpen
…/pull/<n>.diffwith patchtree to see the tree, highlighting, inline/side-by-side views and the review threads below.