Skip to content

Commit

Permalink
fixing linters
Browse files Browse the repository at this point in the history
  • Loading branch information
kdziedzic68 committed Nov 12, 2024
1 parent c626ef3 commit 1448a81
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/ragbits-evaluate/src/ragbits/evaluate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@ def _save(file_path: Path, **data: Any) -> None: # noqa: ANN401
json.dump(data, file, indent=4)


def log_to_file(results: dict[str, Any], output_dir: Path | None = None) -> Path:
"""
Log the evaluation results locally.
Args:
results: The evaluation results.
output_dir: The output directory.
Returns:
The output directory.
"""
output_dir = output_dir or Path(HydraConfig.get().runtime.output_dir)
metrics_file = output_dir / "metrics.json"
results_file = output_dir / "results.json"

_save(metrics_file, metrics=results["metrics"], time_perf=results["time_perf"])
_save(results_file, results=results["results"])

return output_dir


def log_dataset_to_file(dataset: Dataset, output_dir: Path | None = None) -> Path:
"""
Log the evaluation results locally.
Expand Down

0 comments on commit 1448a81

Please sign in to comment.