sda.dashboard.utils.decorators#
Callback Decorators and Utilities.
Reusable decorators and utilities to reduce callback boilerplate.
Classes#
Builder pattern for creating callbacks with consistent configuration. |
Functions#
|
Add error handling to callbacks. |
|
Validate state before callback execution. |
|
Monitor callback performance. |
|
Add logging to callbacks. |
|
Auto-register callback with common decorators. |
|
Create a standard plot callback with common configuration. |
Module Contents#
- sda.dashboard.utils.decorators.with_error_handling(context=ErrorContext.CALLBACK, severity=ErrorSeverity.MEDIUM, fallback_value=None, retry_count=0)#
Add error handling to callbacks.
- Parameters:
context (
ErrorContext) – Context where error occurredseverity (
ErrorSeverity) – Default error severityfallback_value (
Any) – Value to return on errorretry_count (
int) – Number of retries on failure
- sda.dashboard.utils.decorators.with_state_validation(*state_keys)#
Validate state before callback execution.
- Parameters:
*state_keys (
str) – State keys to validate
- sda.dashboard.utils.decorators.with_performance_monitoring(threshold_ms=1000.0)#
Monitor callback performance.
- Parameters:
threshold_ms (
float) – Performance threshold in milliseconds
- sda.dashboard.utils.decorators.with_logging(verbose=True)#
Add logging to callbacks.
- Parameters:
verbose (
bool) – Whether to enable verbose logging
- sda.dashboard.utils.decorators.auto_callback(inputs, outputs, prevent_initial_call=True, **decorator_kwargs)#
Auto-register callback with common decorators.
- Parameters:
inputs (
List[Union[Input,State]]) – Callback inputsoutputs (
List[Output]) – Callback outputsprevent_initial_call (
bool) – Whether to prevent initial call**decorator_kwargs – Arguments for decorators
- class sda.dashboard.utils.decorators.CallbackBuilder(app)#
Builder pattern for creating callbacks with consistent configuration.
- app#
- add_input(component_id, property)#
Add input to callback.
- Parameters:
- Returns:
Builder instance for chaining
- Return type:
- add_state(component_id, property)#
Add state to callback.
- Parameters:
- Returns:
Builder instance for chaining
- Return type:
- add_output(component_id, property)#
Add output to callback.
- Parameters:
- Returns:
Builder instance for chaining
- Return type:
- with_error_handling(context=ErrorContext.CALLBACK, severity=ErrorSeverity.MEDIUM)#
Enable error handling.
- Parameters:
context (
ErrorContext) – Error contextseverity (
ErrorSeverity) – Error severity
- Returns:
Builder instance for chaining
- Return type:
- with_logging(verbose=True)#
Enable logging.
- Parameters:
verbose (
bool) – Whether to enable verbose logging- Returns:
Builder instance for chaining
- Return type:
- with_performance_monitoring(threshold_ms=1000.0)#
Enable performance monitoring.
- Parameters:
threshold_ms (
float) – Performance threshold in milliseconds- Returns:
Builder instance for chaining
- Return type:
- with_state_validation(*state_keys)#
Enable state validation.
- Parameters:
*state_keys (
str) – State keys to validate- Returns:
Builder instance for chaining
- Return type:
- prevent_initial_call(prevent=True)#
Set prevent initial call.
- Parameters:
prevent (
bool) – Whether to prevent initial call- Returns:
Builder instance for chaining
- Return type:
- build(handler)#
Build and register the callback.
- Parameters:
handler (
Callable) – Callback handler function- Returns:
Decorated callback function
- Return type:
Callable
- sda.dashboard.utils.decorators.create_standard_plot_callback(app, plot_type, graph_id, axis_ids, handler, **kwargs)#
Create a standard plot callback with common configuration.
- Parameters:
- Returns:
Configured callback function
- Return type:
Callable