Analysis Orchestrator¶
analysis_orchestrator ¶
Application Layer - Analysis Orchestrator.
This module orchestrates the complete workflow from upload to export, coordinating between multiple application services and core operations.
Classes:
| Name | Description |
|---|---|
AnalysisOrchestrator | High-level coordinator for the complete analysis workflow. |
Notes
- Follows Clean Architecture (depends on abstractions)
- Coordinates but doesn't duplicate logic
- Uses Dependency Injection for testability
- Maintains workflow state through DTOs
Classes¶
AnalysisSessionDTO dataclass ¶
AnalysisSessionDTO(session_id: str, upload_result: Optional[UploadResultDTO], processing_result: Optional[MergedDataDTO], export_results: List[ExportResultDTO], created_at: str, is_complete: bool)
Data Transfer Object for analysis session state.
Attributes:
| Name | Type | Description |
|---|---|---|
session_id | str | Unique identifier for the session |
upload_result | Optional[UploadResultDTO] | Result of file upload |
processing_result | Optional[MergedDataDTO] | Result of data processing |
export_results | List[ExportResultDTO] | List of export operations performed |
created_at | str | ISO format timestamp of session creation |
is_complete | bool | Whether analysis is complete |
AnalysisOrchestrator ¶
AnalysisOrchestrator(upload_handler: UploadHandler, data_processor: DataProcessor, result_exporter: ResultExporter, cache_service: CacheService, progress_tracker: ProgressTracker)
Orchestrate the complete analysis workflow.
Coordinates the entire analysis pipeline from file upload through processing to export. Uses composition and dependency injection to maintain clean architecture principles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upload_handler | UploadHandler | Handler for file uploads | required |
data_processor | DataProcessor | Processor for data merging and analysis | required |
result_exporter | ResultExporter | Exporter for results | required |
cache_service | CacheService | Service for caching data | required |
progress_tracker | ProgressTracker | Tracker for progress updates | required |
Methods:
| Name | Description |
|---|---|
execute_workflow | Execute complete workflow from upload to export |
process_upload | Process file upload step |
process_data | Process data merging step |
export_results | Export results in multiple formats |
get_session_state | Retrieve current session state |
Notes
- Uses dependency injection for all operations
- Maintains session state via DTOs
- Handles errors gracefully with detailed messages
- Updates progress at each workflow step
- Caches intermediate results
Initialize the AnalysisOrchestrator with dependencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upload_handler | UploadHandler | Handler for file uploads | required |
data_processor | DataProcessor | Processor for data merging | required |
result_exporter | ResultExporter | Exporter for results | required |
cache_service | CacheService | Service for caching | required |
progress_tracker | ProgressTracker | Tracker for progress | required |
Notes
All dependencies are injected for testability.
Source code in src/application/services/analysis_orchestrator.py
Functions¶
execute_workflow ¶
execute_workflow(content: str, filename: str, session_id: str, export_formats: Optional[List[ExportFormat]] = None) -> AnalysisSessionDTO
Execute the complete analysis workflow.
Coordinates the entire pipeline: 1. Upload and validate file 2. Process and merge data 3. Export results in requested formats 4. Update session state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content | str | Base64-encoded file content | required |
filename | str | Original filename | required |
session_id | str | Unique session identifier | required |
export_formats | Optional[List[ExportFormat]] | Formats to export (CSV, Excel, JSON), defaults to [CSV] | None |
Returns:
| Type | Description |
|---|---|
AnalysisSessionDTO | Complete session state with results |
Notes
- Creates new session if doesn't exist
- Updates progress at each step
- Handles errors without stopping entire workflow
- Caches results for performance
Source code in src/application/services/analysis_orchestrator.py
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 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
process_upload ¶
Process file upload independently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content | str | Base64-encoded file content | required |
filename | str | Original filename | required |
Returns:
| Type | Description |
|---|---|
UploadResultDTO | Upload processing result |
Notes
Can be used for upload-only operations without full workflow execution.
Source code in src/application/services/analysis_orchestrator.py
process_data ¶
Process data merging independently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset | Dataset | Domain entity with samples | required |
session_id | str | Session identifier | required |
Returns:
| Type | Description |
|---|---|
MergedDataDTO | Processing result |
Notes
Can be used when upload is already complete and only processing is needed.
Source code in src/application/services/analysis_orchestrator.py
export_results ¶
export_results(data: DataFrame, session_id: str, formats: Optional[List[ExportFormat]] = None) -> List[ExportResultDTO]
Export results in multiple formats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data | DataFrame | Data to export | required |
session_id | str | Session identifier for filenames | required |
formats | Optional[List[ExportFormat]] | Export formats, defaults to [CSV] | None |
Returns:
| Type | Description |
|---|---|
List[ExportResultDTO] | List of export results |
Notes
Can be used for exporting existing data without running the full workflow.
Source code in src/application/services/analysis_orchestrator.py
get_session_state ¶
Retrieve current session state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id | str | Session identifier | required |
Returns:
| Type | Description |
|---|---|
Optional[AnalysisSessionDTO] | Session state or None if not found |
Notes
Returns None if session doesn't exist.
Source code in src/application/services/analysis_orchestrator.py
get_progress ¶
Get current progress for a session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id | str | Session identifier | required |
Returns:
| Type | Description |
|---|---|
Optional[ProcessingProgressDTO] | Current progress or None |
Source code in src/application/services/analysis_orchestrator.py
clear_session ¶
Clear session data and cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id | str | Session identifier to clear | required |
Notes
Removes session from memory and clears cache.