Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openagent_eval/reports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion openagent_eval/reports/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,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)
Expand Down
2 changes: 1 addition & 1 deletion openagent_eval/reports/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion openagent_eval/reports/json_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openagent_eval/reports/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion openagent_eval/reports/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,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
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_reports/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading