register_tracer¶
-
passengersim.callbacks.configured.register_tracer(cls: type[TracerT], /, *, name: str | None =
None, parameters_model: type[BaseModel] | None =None, version: str | None =None) type[TracerT][source]¶ -
passengersim.callbacks.configured.register_tracer(*, name: str | None =
None, parameters_model: type[BaseModel] | None =None, version: str | None =None) collections.abc.Callable[[type[TracerT]], type[TracerT]] Make a tracer class available to
config.callbacks, without attaching it.Use it as a class decorator, with or without arguments (
@register_traceror@register_tracer(version="2")), or call it directly,register_tracer(MyTracer). The class is returned unchanged.The hooks, default name, options model, and version come from the class, as for
register_tracer_factory()(seeGenericTracer): the configured tracer is built ascls(**validated_options)and its result is stored under the declaration ID.- Parameters:
- cls : type[GenericTracer], optional¶
The tracer class. Omit it to get a decorator.
- name : str, optional¶
Registry name or alias; defaults to
cls.name. The configuration’s declaration ID names each result table.- parameters_model : type[pydantic.BaseModel], optional¶
Overrides
cls.options_model. If neither is given, a model is derived from the constructor’s signature (seeoptions_model_from_signature()).- version : str, optional¶
Overrides
cls.options_version.
- Returns:
type[GenericTracer] – cls, unchanged; or, without cls, a decorator that registers the class it decorates and returns it unchanged.
- Raises:
TypeError – If cls is not a GenericTracer subclass (a function, a tracer instance, or anything else), or no options model is declared or given and none can be derived from the constructor.
ValueError – If the name is registered by something else, or the class declares no hook or an invalid hook or output.
Notes
Registering again under the same name replaces the earlier registration if it came from the same module-level class (as when a notebook cell is re-run); any other duplicate name is an error.