kempnerpulse.config¶
Cross-cutting tier — parsed configuration.
Turns command-line arguments into a single frozen Config value that the
lifecycle, reader, translate, compute, and present layers all read from. This
module owns parsing and validation only: it builds the argument parser,
resolves the weight preset, applies the backend-aware --poll default, and
reports poll-validation problems as data. It never prints, never exits, and
never installs signal handlers — those are the lifecycle’s responsibility.
Runtime dependencies are the standard library only.
Functions
|
Parse |
Construct the KempnerPulse command-line parser. |
|
|
Validate a |
|
Validate |
Classes
Fully-resolved run configuration, frozen for the process lifetime. |
|
Outcome of poll validation, returned as data for the lifecycle to act on. |
- class kempnerpulse.config.Config[source]¶
Bases:
objectFully-resolved run configuration, frozen for the process lifetime.
- Field semantics:
gpu_idsis the explicit--gpusselection (already a tuple of string ids), orNonewhen the flag was not supplied. Environment / accessibility resolution is the selection layer’s job, not config’s.weightsis normalized to sum to 1;preset_nameis the matching preset name ("ai"/"hpc"/"mem") or"custom".export_specisNone(no export),"default"(--exportwith no argument),"all", or a comma-separated column list.focus_gpuis the id to start focused on, orNone.
- backend: BackendKind¶
- __init__(backend, poll_seconds, source, gpu_ids, show_all, weights, preset_name, export_spec, once, focus_gpu, history_length)¶
- kempnerpulse.config.parse_weights(raw)[source]¶
Validate a
--weightsstring into a normalized 4-tuple.Requires exactly four comma-separated numeric values in
SM,TENSOR,DRAM,GRorder summing to a positive value; the tuple is normalized to sum to 1. Raisesargparse.ArgumentTypeErroron any malformed input so argparse reports it cleanly.
- kempnerpulse.config.build_parser()[source]¶
Construct the KempnerPulse command-line parser.
Returned standalone so callers (and tests) can introspect or reuse it without triggering a parse. Defaults mirror the legacy CLI surface; the weight presets and custom-weight default are sourced from the compute layer’s
PRESETSso the two never drift.- Return type:
- kempnerpulse.config.build_config(argv=None)[source]¶
Parse
argv(orsys.argv) into a frozenConfig.Resolves the backend enum, applies the backend-aware
--polldefault when unset, names the weight preset, and floors the history length. Poll values are not validated here — callvalidate_poll()on the returned config.
- class kempnerpulse.config.PollValidation[source]¶
Bases:
objectOutcome of poll validation, returned as data for the lifecycle to act on.
erroris a user-facing message when the configured poll is invalid (the lifecycle should print it and exit non-zero), elseNone. When the dcgm backend is asked for a sub-floor interval,clampedisTrueandnotecarries an advisory the lifecycle may print to stderr;effective_poll_secondsis the interval that will actually be used.
- kempnerpulse.config.validate_poll(config)[source]¶
Validate
config.poll_secondsagainst the backend, returning data only.- Rules (ported from the legacy CLI):
poll <= 0is an error for any backend.prometheus requires
poll >= 1.0(the exporter’s scrape interval is the true ceiling; sub-second values just duplicate samples).dcgm allows a sub-100ms request but clamps it up to the 100ms profiling floor, reported via
clamped/noterather than printed here.
No printing or exiting happens in this function; the lifecycle owns that.
- Parameters:
config (Config)
- Return type: