sda.dashboard.utils#

Dashboard Utilities.


Utility functions and decorators for dashboard development.

Submodules#

Classes#

CallbackBuilder

Builder pattern for creating callbacks with consistent configuration.

Functions#

auto_callback(inputs, outputs[, prevent_initial_call])

Auto-register callback with common decorators.

create_standard_plot_callback(app, plot_type, ...)

Create a standard plot callback with common configuration.

with_error_handling([context, severity, ...])

Add error handling to callbacks.

with_logging([verbose])

Add logging to callbacks.

with_performance_monitoring([threshold_ms])

Monitor callback performance.

with_state_validation(*state_keys)

Validate state before callback execution.

create_enhanced_test_info_display(test_names)

Create an enhanced test information display with hyperlinks, row counts, and columns.

get_test_columns_sorted(test_name)

Get the sorted list of columns for a test.

get_test_row_count(test_name)

Get the number of rows for a test.

Package Contents#

class sda.dashboard.utils.CallbackBuilder(app)#

Builder pattern for creating callbacks with consistent configuration.

app#
add_input(component_id, property)#

Add input to callback.

Parameters:
  • component_id (str) – Component ID

  • property (str) – Component property

Returns:

Builder instance for chaining

Return type:

CallbackBuilder

add_state(component_id, property)#

Add state to callback.

Parameters:
  • component_id (str) – Component ID

  • property (str) – Component property

Returns:

Builder instance for chaining

Return type:

CallbackBuilder

add_output(component_id, property)#

Add output to callback.

Parameters:
  • component_id (str) – Component ID

  • property (str) – Component property

Returns:

Builder instance for chaining

Return type:

CallbackBuilder

with_error_handling(context=ErrorContext.CALLBACK, severity=ErrorSeverity.MEDIUM)#

Enable error handling.

Parameters:
  • context (ErrorContext) – Error context

  • severity (ErrorSeverity) – Error severity

Returns:

Builder instance for chaining

Return type:

CallbackBuilder

with_logging(verbose=True)#

Enable logging.

Parameters:

verbose (bool) – Whether to enable verbose logging

Returns:

Builder instance for chaining

Return type:

CallbackBuilder

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:

CallbackBuilder

with_state_validation(*state_keys)#

Enable state validation.

Parameters:

*state_keys (str) – State keys to validate

Returns:

Builder instance for chaining

Return type:

CallbackBuilder

prevent_initial_call(prevent=True)#

Set prevent initial call.

Parameters:

prevent (bool) – Whether to prevent initial call

Returns:

Builder instance for chaining

Return type:

CallbackBuilder

build(handler)#

Build and register the callback.

Parameters:

handler (Callable) – Callback handler function

Returns:

Decorated callback function

Return type:

Callable

sda.dashboard.utils.auto_callback(inputs, outputs, prevent_initial_call=True, **decorator_kwargs)#

Auto-register callback with common decorators.

Parameters:
  • inputs (List[Union[Input, State]]) – Callback inputs

  • outputs (List[Output]) – Callback outputs

  • prevent_initial_call (bool) – Whether to prevent initial call

  • **decorator_kwargs – Arguments for decorators

sda.dashboard.utils.create_standard_plot_callback(app, plot_type, graph_id, axis_ids, handler, **kwargs)#

Create a standard plot callback with common configuration.

Parameters:
  • app (dash.Dash) – Dash application

  • plot_type (str) – Type of plot (scatter, line, etc.)

  • graph_id (str) – Graph component ID

  • axis_ids (List[str]) – List of axis component IDs

  • handler (Callable) – Plot handler function

  • **kwargs – Additional configuration

Returns:

Configured callback function

Return type:

Callable

sda.dashboard.utils.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 occurred

  • severity (ErrorSeverity) – Default error severity

  • fallback_value (Any) – Value to return on error

  • retry_count (int) – Number of retries on failure

sda.dashboard.utils.with_logging(verbose=True)#

Add logging to callbacks.

Parameters:

verbose (bool) – Whether to enable verbose logging

sda.dashboard.utils.with_performance_monitoring(threshold_ms=1000.0)#

Monitor callback performance.

Parameters:

threshold_ms (float) – Performance threshold in milliseconds

sda.dashboard.utils.with_state_validation(*state_keys)#

Validate state before callback execution.

Parameters:

*state_keys (str) – State keys to validate

sda.dashboard.utils.create_enhanced_test_info_display(test_names)#

Create an enhanced test information display with hyperlinks, row counts, and columns.

Parameters:

test_names (Union[str, List[str]]) – Single test name or list of test names

Returns:

Enhanced test information display component

Return type:

html.Div

sda.dashboard.utils.get_test_columns_sorted(test_name)#

Get the sorted list of columns for a test.

Parameters:

test_name (str) – The name of the test

Returns:

Sorted list of column names

Return type:

List[str]

sda.dashboard.utils.get_test_row_count(test_name)#

Get the number of rows for a test.

Parameters:

test_name (str) – The name of the test

Returns:

Number of rows in the test data

Return type:

int