Plot Service¶
plot_service ¶
Plot Service: Orchestration and Caching.
Main service coordinating plot generation with multi-layer caching.
Classes:
| Name | Description |
|---|---|
PlotService | Orchestrates plot generation pipeline with caching. |
Notes
Implements Facade Pattern, providing simple interface while managing: - Configuration loading - Strategy creation - Multi-layer caching - Error handling
Classes¶
PlotService ¶
Central service for plot generation with caching.
This service implements the Facade pattern, providing a simple interface for plot generation while managing complex operations behind the scenes: - Load YAML configuration - Create strategy via factory - Check multi-layer cache - Generate plot - Cache results
Attributes:
| Name | Type | Description |
|---|---|---|
config_loader | PlotConfigLoader | Configuration loader instance. |
factory | PlotFactory | Plot factory instance. |
cache_manager | GraphCacheManager | Cache manager instance. |
Examples:
>>> service = PlotService()
>>> fig = service.generate_plot(
... "UC-2.1",
... df,
... filters={"uc-2-1-range-slider": [10, 50]}
... )
Initialize plot service with dependencies.
Source code in src/application/plot_services/plot_service.py
Functions¶
generate_plot ¶
generate_plot(use_case_id: str, data: DataFrame, filters: Optional[Dict[str, Any]] = None, customizations: Optional[Any] = None, force_refresh: bool = False) -> go.Figure
Generate plot for given use case with caching.
Pipeline: 1. Load configuration from YAML 2. Generate cache keys 3. Check graph cache 4. If miss: Create strategy and generate plot 5. Cache result 6. Return figure
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
use_case_id | str | Use case identifier (e.g., "UC-2.1"). | required |
data | DataFrame | Input data. | required |
filters | Optional[Dict[str, Any]] | Filters to apply (e.g., {"uc-2-1-range-slider": [10, 50]}). | None |
customizations | Optional[Any] | Additional customizations (future feature). | None |
force_refresh | bool | Force cache refresh. | False |
Returns:
| Type | Description |
|---|---|
Figure | Generated Plotly figure. |
Raises:
| Type | Description |
|---|---|
ValueError | If data validation fails. |
FileNotFoundError | If configuration file not found. |
Examples:
Source code in src/application/plot_services/plot_service.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
clear_cache ¶
Clear cache for specific use case or all.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
use_case_id | Optional[str] | Use case ID to clear. If None, clears all. | None |