From 2444de9ca2f32dfafd4a69f445abc782801ef9a2 Mon Sep 17 00:00:00 2001 From: Muhamed Fazal PS Date: Wed, 15 Jul 2026 14:31:11 +0530 Subject: [PATCH] Fix #87: Rename _ensure_output_dir to _prepare_output_file --- openagent_eval/reports/base.py | 4 ++-- openagent_eval/reports/comparison.py | 2 +- openagent_eval/reports/html.py | 2 +- openagent_eval/reports/json_report.py | 2 +- openagent_eval/reports/markdown.py | 2 +- openagent_eval/reports/terminal.py | 2 +- tests/unit/test_reports/test_base.py | 8 ++++---- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openagent_eval/reports/base.py b/openagent_eval/reports/base.py index 901b705..f4873d3 100644 --- a/openagent_eval/reports/base.py +++ b/openagent_eval/reports/base.py @@ -107,8 +107,8 @@ def generate_to_file(self, report: Any, output_path: Path | str) -> Path: """ ... - def _ensure_output_dir(self, output_path: Path | str) -> Path: - """Ensure the output directory exists. + def _prepare_output_file(self, output_path: Path | str) -> Path: + """Ensure the parent directory exists and return the resolved file path. Args: output_path: Target file path. diff --git a/openagent_eval/reports/comparison.py b/openagent_eval/reports/comparison.py index 2fb0324..2289c5a 100644 --- a/openagent_eval/reports/comparison.py +++ b/openagent_eval/reports/comparison.py @@ -159,7 +159,7 @@ def generate_to_file(self, report: Any, output_path: Path | str) -> Path: Returns: Path to the written file. """ - path = self._ensure_output_dir(output_path) + path = self._prepare_output_file(output_path) if not str(path).endswith(".txt"): path = path / "comparison.txt" content = self.generate(report) diff --git a/openagent_eval/reports/html.py b/openagent_eval/reports/html.py index 19a1f84..850e157 100644 --- a/openagent_eval/reports/html.py +++ b/openagent_eval/reports/html.py @@ -152,7 +152,7 @@ def generate_to_file(self, report: Any, output_path: Path | str) -> Path: path = path / "report.html" elif path.suffix.lower() != ".html": path = path.with_suffix(".html") - path = self._ensure_output_dir(path) + path = self._prepare_output_file(path) content = self.generate(report) path.write_text(content, encoding="utf-8") return path diff --git a/openagent_eval/reports/json_report.py b/openagent_eval/reports/json_report.py index ce8020f..19a72f0 100644 --- a/openagent_eval/reports/json_report.py +++ b/openagent_eval/reports/json_report.py @@ -129,7 +129,7 @@ def generate_to_file(self, report: Any, output_path: Path | str) -> Path: path = Path(output_path) if not str(path).endswith(".json"): path = path / "report.json" - path = self._ensure_output_dir(path) + path = self._prepare_output_file(path) content = self.generate(report) path.write_text(content, encoding="utf-8") return path diff --git a/openagent_eval/reports/markdown.py b/openagent_eval/reports/markdown.py index 81ee101..4f8ba35 100644 --- a/openagent_eval/reports/markdown.py +++ b/openagent_eval/reports/markdown.py @@ -179,7 +179,7 @@ def generate_to_file(self, report: Any, output_path: Path | str) -> Path: path = Path(output_path) if not str(path).endswith(".md"): path = path / "report.md" - path = self._ensure_output_dir(path) + path = self._prepare_output_file(path) content = self.generate(report) path.write_text(content, encoding="utf-8") return path diff --git a/openagent_eval/reports/terminal.py b/openagent_eval/reports/terminal.py index 9093030..b4083ef 100644 --- a/openagent_eval/reports/terminal.py +++ b/openagent_eval/reports/terminal.py @@ -108,7 +108,7 @@ def generate_to_file(self, report: Any, output_path: Path | str) -> Path: Returns: Path to the written file. """ - path = self._ensure_output_dir(output_path) + path = self._prepare_output_file(output_path) content = self.generate(report) path.write_text(content, encoding="utf-8") return path diff --git a/tests/unit/test_reports/test_base.py b/tests/unit/test_reports/test_base.py index 6d3d68a..94299ab 100644 --- a/tests/unit/test_reports/test_base.py +++ b/tests/unit/test_reports/test_base.py @@ -118,19 +118,19 @@ def generate_to_file(self, report: Any, output_path: Path | str) -> Path: result = report_gen.generate(evaluation_report) assert result == "test report" - def test_ensure_output_dir(self, tmp_path: Path) -> None: - """_ensure_output_dir creates parent directories.""" + def test_prepare_output_file(self, tmp_path: Path) -> None: + """_prepare_output_file creates parent directories.""" class ConcreteReport(ReportGenerator): def generate(self, report: Any) -> str: return "" def generate_to_file(self, report: Any, output_path: Path | str) -> Path: - return self._ensure_output_dir(output_path) + return self._prepare_output_file(output_path) report_gen = ConcreteReport() target = tmp_path / "subdir" / "report.txt" - result = report_gen._ensure_output_dir(target) + result = report_gen._prepare_output_file(target) assert result.parent.exists() def test_extract_metric_averages(self, pipeline_result_with_data: Any) -> None: