register_callback_factory¶
-
passengersim.callbacks.register_callback_factory(name: str, *, factory: Callable[[BaseModel], Any], when: 'initialize_sample' | 'begin_sample' | 'daily' | 'end_sample' | 'finalize_sample', parameters_model: type[BaseModel], version: str, output_name: str | None =
None) None[source]¶ Make a factory available to YAML declarations without attaching it.
- Parameters:
- name : str¶
Unique registry name. Duplicate registration is always an error.
- factory : callable¶
Receives one validated parameter-model instance and returns a fresh callback. Sample hooks receive a simulation; daily hooks also receive days prior to departure.
- when : {"initialize_sample", "begin_sample", "daily", "end_sample", "finalize_sample"}¶
Lifecycle hook at which the returned callback runs.
- parameters_model : type[pydantic.BaseModel]¶
Schema for factory options; preferably configured with extra=”forbid”.
- version : str¶
Implementation version checked only when explicitly required in YAML.
- output_name : str or None, optional¶
Required canonical result name for a factory returning a GenericTracer.
- Raises:
ValueError – If the name is duplicated, the hook is invalid, or the output is reserved.
TypeError – If the factory or parameter model is invalid.