nvalchemi.hooks.ReportingState#
- class nvalchemi.hooks.ReportingState(*, max_messages=100, started_at_s=<factory>, event_count=0, last_event_at_s=None, last_stage=None, last_step_count=None, last_global_rank=None, messages=<factory>, metadata=<factory>)[source]#
Mutable state shared by a reporting orchestrator and its reporters.
The state object intentionally stores only orchestration metadata: counters, timestamps, recent messages, and an extensible metadata mapping. Workflow values such as losses, schedulers, or dynamics counters should be read from the hook context rather than duplicated here.
- Parameters:
max_messages (int)
started_at_s (float)
event_count (int)
last_event_at_s (float | None)
last_stage (str | None)
last_step_count (int | None)
last_global_rank (int | None)
messages (list[ReporterMessage])
metadata (dict[str, Any])
- max_messages#
Maximum number of recent messages retained.
- Type:
int
- started_at_s#
Monotonic time when the state was created.
- Type:
float
- event_count#
Number of reporting events dispatched by the orchestrator.
- Type:
int
- last_event_at_s#
Monotonic time of the latest reporting event.
- Type:
float | None
- last_stage#
Name of the latest reported hook stage.
- Type:
str | None
- last_step_count#
Step count from the latest reported context, when available.
- Type:
int | None
- last_global_rank#
Rank from the latest reported context, when available.
- Type:
int | None
- messages#
Bounded list of recent reporting messages.
- Type:
list[ReporterMessage]
- metadata#
Scratch space for reporters that need shared per-run state.
- Type:
dict[str, Any]
- add_message(level, message, *, reporter=None, ctx=None, stage=None)[source]#
Append a bounded recent message.
- Parameters:
level ({"info", "warning", "error"}) – Message severity.
message (str) – Human-readable message.
reporter (object | None, optional) – Reporter associated with the message.
ctx (HookContext | None, optional) – Context associated with the message.
stage (Enum | None, optional) – Hook stage associated with the message.
- Returns:
The message object appended to
messages.- Return type:
ReporterMessage
- mark_event(ctx, stage)[source]#
Record that a reporting event was dispatched.
- Parameters:
ctx (HookContext) – Workflow context passed to the reporting orchestrator.
stage (Enum) – Hook stage being reported.
- Return type:
None