sda.dashboard.utils.decorators ============================== .. py:module:: sda.dashboard.utils.decorators .. autoapi-nested-parse:: Callback Decorators and Utilities. =================================== Reusable decorators and utilities to reduce callback boilerplate. Classes ------- .. autoapisummary:: sda.dashboard.utils.decorators.CallbackBuilder Functions --------- .. autoapisummary:: sda.dashboard.utils.decorators.with_error_handling sda.dashboard.utils.decorators.with_state_validation sda.dashboard.utils.decorators.with_performance_monitoring sda.dashboard.utils.decorators.with_logging sda.dashboard.utils.decorators.auto_callback sda.dashboard.utils.decorators.create_standard_plot_callback Module Contents --------------- .. py:function:: with_error_handling(context = ErrorContext.CALLBACK, severity = ErrorSeverity.MEDIUM, fallback_value = None, retry_count = 0) Add error handling to callbacks. :param context: Context where error occurred :type context: :py:class:`ErrorContext` :param severity: Default error severity :type severity: :py:class:`ErrorSeverity` :param fallback_value: Value to return on error :type fallback_value: :py:class:`Any` :param retry_count: Number of retries on failure :type retry_count: :py:class:`int` .. py:function:: with_state_validation(*state_keys) Validate state before callback execution. :param \*state_keys: State keys to validate :type \*state_keys: :py:class:`str` .. py:function:: with_performance_monitoring(threshold_ms = 1000.0) Monitor callback performance. :param threshold_ms: Performance threshold in milliseconds :type threshold_ms: :py:class:`float` .. py:function:: with_logging(verbose = True) Add logging to callbacks. :param verbose: Whether to enable verbose logging :type verbose: :py:class:`bool` .. py:function:: auto_callback(inputs, outputs, prevent_initial_call = True, **decorator_kwargs) Auto-register callback with common decorators. :param inputs: Callback inputs :type inputs: :py:class:`List[Union[Input`, :py:class:`State]]` :param outputs: Callback outputs :type outputs: :py:class:`List[Output]` :param prevent_initial_call: Whether to prevent initial call :type prevent_initial_call: :py:class:`bool` :param \*\*decorator_kwargs: Arguments for decorators .. py:class:: CallbackBuilder(app) Builder pattern for creating callbacks with consistent configuration. .. py:attribute:: app .. py:method:: add_input(component_id, property) Add input to callback. :param component_id: Component ID :type component_id: :py:class:`str` :param property: Component property :type property: :py:class:`str` :returns: Builder instance for chaining :rtype: :py:class:`CallbackBuilder` .. py:method:: add_state(component_id, property) Add state to callback. :param component_id: Component ID :type component_id: :py:class:`str` :param property: Component property :type property: :py:class:`str` :returns: Builder instance for chaining :rtype: :py:class:`CallbackBuilder` .. py:method:: add_output(component_id, property) Add output to callback. :param component_id: Component ID :type component_id: :py:class:`str` :param property: Component property :type property: :py:class:`str` :returns: Builder instance for chaining :rtype: :py:class:`CallbackBuilder` .. py:method:: with_error_handling(context = ErrorContext.CALLBACK, severity = ErrorSeverity.MEDIUM) Enable error handling. :param context: Error context :type context: :py:class:`ErrorContext` :param severity: Error severity :type severity: :py:class:`ErrorSeverity` :returns: Builder instance for chaining :rtype: :py:class:`CallbackBuilder` .. py:method:: with_logging(verbose = True) Enable logging. :param verbose: Whether to enable verbose logging :type verbose: :py:class:`bool` :returns: Builder instance for chaining :rtype: :py:class:`CallbackBuilder` .. py:method:: with_performance_monitoring(threshold_ms = 1000.0) Enable performance monitoring. :param threshold_ms: Performance threshold in milliseconds :type threshold_ms: :py:class:`float` :returns: Builder instance for chaining :rtype: :py:class:`CallbackBuilder` .. py:method:: with_state_validation(*state_keys) Enable state validation. :param \*state_keys: State keys to validate :type \*state_keys: :py:class:`str` :returns: Builder instance for chaining :rtype: :py:class:`CallbackBuilder` .. py:method:: prevent_initial_call(prevent = True) Set prevent initial call. :param prevent: Whether to prevent initial call :type prevent: :py:class:`bool` :returns: Builder instance for chaining :rtype: :py:class:`CallbackBuilder` .. py:method:: build(handler) Build and register the callback. :param handler: Callback handler function :type handler: :py:class:`Callable` :returns: Decorated callback function :rtype: :py:class:`Callable` .. py:function:: create_standard_plot_callback(app, plot_type, graph_id, axis_ids, handler, **kwargs) Create a standard plot callback with common configuration. :param app: Dash application :type app: :py:class:`dash.Dash` :param plot_type: Type of plot (scatter, line, etc.) :type plot_type: :py:class:`str` :param graph_id: Graph component ID :type graph_id: :py:class:`str` :param axis_ids: List of axis component IDs :type axis_ids: :py:class:`List[str]` :param handler: Plot handler function :type handler: :py:class:`Callable` :param \*\*kwargs: Additional configuration :returns: Configured callback function :rtype: :py:class:`Callable`