kempnerpulse.selection

Cross-cutting tier — GPU visibility selection.

Resolves which GPU ids the dashboard should monitor, by precedence, from an explicit --gpus list, --show-all, the SLURM/CUDA visibility environment, and finally the set of accessible ids. The result is always intersected (“clamped”) with the accessible set so a selection can never widen visibility beyond what the process can actually reach.

This module reads os.environ and parses id strings; it does no I/O and never shells out. Runtime dependencies are the standard library only.

Classes

GPUSelector

Resolve the set of GPU ids to monitor by precedence.

class kempnerpulse.selection.GPUSelector[source]

Bases: object

Resolve the set of GPU ids to monitor by precedence.

Parameters:
  • explicit – the raw --gpus value, or None if unset.

  • disable_auto – the --show-all flag — ignore the environment and use the full accessible set.

  • accessible – ids the process can actually reach (from nvidia-smi / dcgmi). None means “unknown”, in which case no clamping is applied and selections pass through unfiltered.

__init__(explicit, disable_auto=False, accessible=None)[source]
Parameters:
  • explicit (str | None)

  • disable_auto (bool)

  • accessible (Set[str] | None)

Return type:

None

resolve()[source]

Return (allowed_ids, reason, source_value).

allowed_ids is the clamped id set to monitor (None = “all accessible, unfiltered”). reason names the precedence rule that decided it ("--gpus", an env var name, or "all"). source_value is the raw string that rule used, or None.

Return type:

Tuple[Set[str] | None, str, str | None]