register_daily_callback

passengersim.callbacks.register_daily_callback(callback: collections.abc.Callable[[CallbackMixin, int], dict | None] | GenericTracer | RmSys | None = None, *, priority: int | None = None, skip_burn: bool | None = None, name: str | None = None) → collections.abc.Callable[[CallbackMixin, int], dict | None] | GenericTracer

Deprecated global registration for the daily 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.daily_callback(...) or an explicit CallbackMixin bundle with bundle.apply_callback_functions(sim). Calls emit DeprecationWarning.

Register a function to be triggered each day during a sample.

The callback runs at an offset, in seconds, from the overnight trigger time. The offset is the priority option if given, else the callback’s own priority attribute if it has one, and otherwise one second. RM systems run at -1 and the simulation’s own DCP and daily data capture at 0, so by default a callback sees each day after both have finished. Use a negative priority to run it before the simulation’s bookkeeping, or below -1 to run it before the RM systems as well.

A priority of zero is not allowed, because it would tie with the simulation’s own bookkeeping in an arbitrary order. It is rejected here, and again when a run starts if it was set after registration. The priority must also be a whole number of seconds: a value that clearly names one, such as 1.0 or "1", is used as that integer, and anything else (0.5, "1.5", True, "high") is rejected rather than rounded. A callback attached while a sample is running takes effect from the next sample.

The options can be given with the callback, or to use this method as a decorator:

@sim.daily_callback(priority=-5, skip_burn=True, name="nogo")
def count_nogo(sim, days_prior): ...
callbackCallable[[Simulation, int], dict | None] or GenericTracer, optional

The callback function to register. It should accept two arguments, which will be the Simulation object and the days_prior, and return a dictionary of interesting things to store, or nothing. Omit it to use this method as a decorator with options.

priorityint, optional

Offset in seconds from the overnight trigger time; see above.

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 daily key, so they cannot collide with other callbacks’ keys; 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.

ValueError

If the priority is zero or not a whole number of seconds, the name is reserved or used by a tracer, or the callback is a tracer declaring a hook other than daily.