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.

fix: per-registry CSV path in generate_report

Louis Choquel7b3dd10d65f0
diff --git a/pipelex/reporting/reporting_manager.py b/pipelex/reporting/reporting_manager.py
index 267d5b272..f4756df23 100644
--- a/pipelex/reporting/reporting_manager.py
+++ b/pipelex/reporting/reporting_manager.py
@@ -367,14 +367,9 @@ class ReportingManager(ReportingProtocol):
@override
def generate_report(self, pipeline_run_id: str | None = None, print_to_console: bool = True):
- cost_report_file_path: Path | None = None
- if self._reporting_config.is_generate_cost_report_file_enabled:
+ is_csv_enabled = self._reporting_config.is_generate_cost_report_file_enabled
+ if is_csv_enabled:
ensure_path(self._reporting_config.cost_report_dir_path)
- cost_report_file_path = get_incremental_file_path(
- base_path=self._reporting_config.cost_report_dir_path,
- base_name=self._reporting_config.cost_report_base_name,
- extension=self._reporting_config.cost_report_extension,
- )
registries_to_process: dict[str, UsageRegistry] = {}
if pipeline_run_id:
@@ -383,6 +378,13 @@ class ReportingManager(ReportingProtocol):
registries_to_process = self._usage_registries
for run_id, registry in registries_to_process.items():
+ cost_report_file_path: Path | None = None
+ if is_csv_enabled:
+ cost_report_file_path = get_incremental_file_path(
+ base_path=self._reporting_config.cost_report_dir_path,
+ base_name=self._reporting_config.cost_report_base_name,
+ extension=self._reporting_config.cost_report_extension,
+ )
CostRegistry.generate_report(
pipeline_run_id=run_id,
tokens_usages=registry.get_current_tokens_usage(),