Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

feature/generate-report-all-pipelines (#76)

Thomas Hebrard805f3ee61a63
diff --git a/pipelex/reporting/reporting_manager.py b/pipelex/reporting/reporting_manager.py
index 761e5582a..708a4f416 100644
--- a/pipelex/reporting/reporting_manager.py
+++ b/pipelex/reporting/reporting_manager.py
@@ -94,7 +94,6 @@ class ReportingManager(ReportingProtocol):
@override
def generate_report(self, pipeline_run_id: Optional[str] = None):
- pipeline_run_id = pipeline_run_id or SpecialPipelineId.UNTITLED
cost_report_file_path: Optional[str] = None
if self._reporting_config.is_generate_cost_report_file_enabled:
ensure_path(self._reporting_config.cost_report_dir_path)
@@ -104,13 +103,19 @@ class ReportingManager(ReportingProtocol):
extension=self._reporting_config.cost_report_extension,
)
- registry = self._get_registry(pipeline_run_id)
- CostRegistry.generate_report(
- pipeline_run_id=pipeline_run_id,
- llm_tokens_usages=registry.get_current_tokens_usage(),
- unit_scale=self._reporting_config.cost_report_unit_scale,
- cost_report_file_path=cost_report_file_path,
- )
+ registries_to_process: Dict[str, UsageRegistry] = {}
+ if pipeline_run_id:
+ registries_to_process = {pipeline_run_id: self._get_registry(pipeline_run_id)}
+ else:
+ registries_to_process = self._usage_registries
+
+ for run_id, registry in registries_to_process.items():
+ CostRegistry.generate_report(
+ pipeline_run_id=run_id,
+ llm_tokens_usages=registry.get_current_tokens_usage(),
+ unit_scale=self._reporting_config.cost_report_unit_scale,
+ cost_report_file_path=cost_report_file_path,
+ )
@override
def close_registry(self, pipeline_run_id: str):