streamlit_dashboard.utility_classes namespace¶
Submodules¶
streamlit_dashboard.utility_classes.base_report_page module¶
- class streamlit_dashboard.utility_classes.base_report_page.BaseReportPage(title: str)¶
Bases:
RenderableStandardizes the rendering pipeline for all analytical report pages.
This class breaks down UI generation into a predictable, synchronous lifecycle: 1. Render controls (capture inputs). 2. Generate figures (process data). 3. Render figures (display outputs). This strict pipeline allows higher-level orchestrators to intercept the process mid-cycle (e.g., to mutate generated figures before they are drawn).
- Parameters:
title (str) – The title of the page, acting as its base instance ID.
- generate_figures(parameters: Dict[str, Any])¶
Processes parameters and generates the underlying data/figures for the report.
- Parameters:
parameters (Dict[str, Any]) – The dictionary of user inputs captured from render_controls.
- Returns:
A dictionary of computed outputs or Plotly figures.
- Return type:
Dict[str, Any]
- static get_page_name()¶
Retrieves the human-readable name of the report for UI selection menus.
- Returns:
The display name of the report.
- Return type:
str
- get_syncable_figure_keys() List[str]¶
Identifies which generated figures support external axis synchronization for when two of the same report are displayed side by side.
This should really only be used for graphs for which axis synchronization makes sense (like bar charts that show quantities not percentages)
- Returns:
A list of dictionary keys corresponding to figures in output_data that can have their Y-axes scaled dynamically by a parent orchestrator.
- Return type:
List[str]
- render(container: DeltaGenerator)¶
Executes the standardized report lifecycle.
Sequentially chains control rendering, data generation, and figure drawing, passing state safely between each phase and halting if user parameters are missing.
- Parameters:
container (DeltaGenerator) – The Streamlit layout container for the entire report.
- render_controls(container: DeltaGenerator) Dict[str, Any]¶
Renders the input widgets required to parameterize the report.
- Parameters:
container (DeltaGenerator) – The Streamlit container to draw the widgets onto.
- Returns:
A dictionary of user-selected parameters, or None if inputs are invalid.
- Return type:
Dict[str, Any]
- render_figures(container: DeltaGenerator, output_data: Dict[str, Any])¶
Draws the previously generated figures and data onto the screen.
- Parameters:
container (DeltaGenerator) – The Streamlit container to draw the visuals onto.
output_data (Dict[str, Any]) – The computed results returned by generate_figures.
- class streamlit_dashboard.utility_classes.base_report_page.Renderable(instance_id: str)¶
Bases:
ABCAbstract base class for UI components drawn to a Streamlit container.
Provides a strict contract for rendering and manages unique identifier generation. This structure is critical in Streamlit to prevent widget state collisions when multiple instances of the same UI component are rendered simultaneously.
- Parameters:
instance_id (str) – A unique identifier for this specific rendered instance.
- get_widget_key(widget_unique_id: str) str¶
Generates a globally unique Streamlit widget key for this specific instance.
- Parameters:
widget_unique_id (str) – The local identifier for the specific widget.
- Returns:
A concatenated string combining the instance ID and widget ID.
- Return type:
str
- abstractmethod render(container: DeltaGenerator)¶
Renders the component’s UI elements onto the specified Streamlit container.
- Parameters:
container (DeltaGenerator) – The Streamlit layout element where this component will be drawn.
streamlit_dashboard.utility_classes.dashboard_config_parser module¶
- class streamlit_dashboard.utility_classes.dashboard_config_parser.DashboardConfig(filename: str)¶
Bases:
objectCentral manager for application configuration state and schema validation.
This class handles the serialization, parsing, and strict validation of the YAML configuration file. It acts as the single source of truth for all external Neoserra data endpoints and logging behaviors, abstracting the dictionary traversal away from the reporting classes.
- Parameters:
filename (str) – The filepath to the target YAML configuration file.
- get_clients_list_urls() ExportModulePair¶
Retrieves the paired endpoints for the client list dataset.
- Returns:
An object containing the current and previous fiscal period URLs.
- Return type:
- get_funding_milestones_urls() ExportModulePair¶
Retrieves the paired endpoints for the funding milestones dataset.
- Returns:
An object containing the current and previous fiscal period URLs.
- Return type:
- get_log_level() int¶
Translates the human-readable logging level from the configuration file into system constants.
Maps string values (e.g., “DEBUG”, “WARNING”) to their corresponding integer values required by the native Python logging module.
- Returns:
The integer constant representing the logging severity level.
- Return type:
int
- get_log_path() str | None¶
Retrieves the configured file path for the application’s rotating file logger.
- Returns:
The target filepath, or None if the configuration is missing.
- Return type:
str | None
- get_nbs_milestones_urls() ExportModulePair¶
Retrieves the paired endpoints for the New Business Starts dataset.
- Returns:
An object containing the current and previous fiscal period URLs.
- Return type:
- get_trainings_urls() ExportModulePair¶
Retrieves the paired endpoints for the training events dataset.
- Returns:
An object containing the current and previous fiscal period URLs.
- Return type:
- load()¶
Reads the configuration file from disk and enforces strict schema validation.
Acts as a fail-fast gateway for the application environment. It manually verifies the existence of every required organizational key (export modules, fiscal periods, and logging parameters). If the YAML file is structurally malformed or missing endpoints, it immediately raises explicit KeyErrors to halt application boot, preventing cascading fetch failures later.
- save()¶
Serializes the current in-memory configuration state to the YAML file on disk.
- set_clients_list_current_fy_url(current_fy_url: str)¶
Updates the in-memory endpoint URL for the current fiscal period’s client dataset.
- set_clients_list_prev_fy_url(prev_fy_url: str)¶
Updates the in-memory endpoint URL for the previous fiscal period’s client dataset.
- set_funding_milestones_current_fy_url(current_fy_url: str)¶
Updates the in-memory endpoint URL for the current fiscal period’s funding milestones dataset.
- set_funding_milestones_prev_fy_url(prev_fy_url: str)¶
Updates the in-memory endpoint URL for the previous fiscal period’s funding milestones dataset.
- set_nbs_milestones_current_fy_url(current_fy_url: str)¶
Updates the in-memory endpoint URL for the current fiscal period’s New Business Starts dataset.
- set_nbs_milestones_prev_fy_url(prev_fy_url: str)¶
Updates the in-memory endpoint URL for the previous fiscal period’s New Business Starts dataset.
- set_trainings_current_fy_url(current_fy_url: str)¶
Updates the in-memory endpoint URL for the current fiscal period’s training events dataset.
- set_trainings_prev_fy_url(prev_fy_url: str)¶
Updates the in-memory endpoint URL for the previous fiscal period’s training events dataset.
- static write_template(filename: str)¶
Bootstraps a new environment by generating a default configuration file on disk.
Writes the hardcoded TEMPLATE_DICT schema to the specified path to ensure administrators have the correct structural format when deploying the dashboard for the first time.
- Parameters:
filename (str) – The target filepath for the generated YAML file.
- class streamlit_dashboard.utility_classes.dashboard_config_parser.ExportModulePair(current_fy: str | None = None, prev_fy: str | None = None)¶
Bases:
objectData structure pairing data export endpoints across adjacent fiscal periods.
This class groups the URLs for the current and previous fiscal years, allowing the application to easily pass paired historical and active data sources to downstream report pipelines.
- current_fy: str | None = None¶
- prev_fy: str | None = None¶
streamlit_dashboard.utility_classes.figure_with_max_y module¶
- class streamlit_dashboard.utility_classes.figure_with_max_y.FigureWithMaxY¶
Bases:
TypedDictA helper container class that gets used by report pages to encapsulate Plotly figures along with the maximum y value represented on the figures.
This aids in axis synchronization when two of the same report are shown side by side
- figure: Figure¶
- max_y: float¶
- streamlit_dashboard.utility_classes.figure_with_max_y.find_fig_max_y_and_generate_wrapper(fig: Figure) FigureWithMaxY¶
Helper to automatically extract the max Y value from a Plotly figure and wrap it in the FigureWithMaxY utility class.