nvalchemi.hooks.HookRegistryMixin#
- class nvalchemi.hooks.HookRegistryMixin[source]#
Mixin providing flat-list hook storage and dispatch.
The host class must provide a
step_countattribute. Override_build_contextto populate workflow-specific fields.Set
_stage_typeon the host class to restrict which stage enum types may be registered. When set,register_hookraisesTypeErrorifhook.stageis not an instance of the declared type(s).- step_count#
Current step number (must be provided by the engine).
- Type:
int
- _stage_type#
Accepted stage enum type(s).
Nonedisables validation.- Type:
type[Enum] | tuple[type[Enum], …] | None
- register_hook(hook, stage=None)[source]#
Register a hook.
- Parameters:
hook (Hook) – Hook to register.
stage (Enum | None) – If provided, assigns
hook.stage = stagebefore validation. This allows stage-agnostic hooks (constructed withstage=None) to receive their stage at registration time.
- Raises:
ValueError – If
hook.frequencyis not a positive integer.TypeError – If
hook.stageisNoneafter assignment and the hook does not define_runs_on_stage, or ifhook.stageis not an instance of the accepted_stage_typedeclared on the engine and the hook does not define_runs_on_stage(cross-category hooks that manage their own stage dispatch bypass this check).
- Return type:
None