register_finalize_sample_callback

passengersim.callbacks.register_finalize_sample_callback(callback: Callable[[CallbackMixin], dict | None] | GenericTracer | None = None, *, skip_burn: bool | None = None, name: str | None = None) → Callable[[CallbackMixin], dict | None] | GenericTracer

Deprecated global registration for the finalize_sample hook.

For a reusable callback, register it with register_callback (a function) or register_tracer (a tracer class) and select it in config.callbacks; those do not attach it to every simulation. For development and testing, use sim.finalize_sample_callback(...) or an explicit CallbackMixin bundle with bundle.apply_callback_functions(sim). Calls emit DeprecationWarning.

Register a synchronous callback after sample bookkeeping finishes.

Callbacks run after departure statistics, history rollover, database commit, and other bookkeeping updates. They observe post-bookkeeping state and cannot change statistics already recorded. Use end_sample to access pre-bookkeeping state. Their execution is included in sample timing, before diagnostics are published. They run only on successful completion, not as exception cleanup; callback failures propagate after bookkeeping has completed. Configured callbacks run first, followed by manual callbacks, each in registration order. Event priority does not apply. Exceptions propagate.

callbackCallable[[Simulation], dict | None] or GenericTracer, optional

Callback receiving the simulation. Returned dictionaries are stored under callback_data.finalize_sample with trial/sample keys. Omit it to use this method as a decorator with options.

skip_burnbool, optional

If True, the callback is not called during burn-in samples.

namestr, optional

Store returned dictionaries under callback_data.<name> instead of the shared hook key; for a tracer, its result name.

Callable or GenericTracer

The callback, or the fresh copy of a tracer. Without callback, a decorator that registers the function it decorates.