Skip to content

Commit

Permalink
fix(cli): use dumpers for exporting
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Jan 10, 2025
1 parent 564bcd0 commit 3268d86
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/cbrkit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.. include:: ../../cli.md
"""

import json
import os
import sys
from pathlib import Path
Expand Down Expand Up @@ -45,8 +44,7 @@ def retrieve(
result = cbrkit.retrieval.apply_queries(casebase, queries, retrievers)

if output_path:
with output_path.with_suffix(".json").open("w") as fp:
json.dump(result.as_dict(), fp, indent=2)
cbrkit.dumpers.file(result.as_dict(), output_path)

if print_ranking or print_similarities:
for query_key, query_result in result.final_step.queries.items():
Expand Down Expand Up @@ -79,8 +77,7 @@ def reuse(
result = cbrkit.reuse.apply_queries(casebase, queries, reusers)

if output_path:
with output_path.with_suffix(".json").open("w") as fp:
json.dump(result.as_dict(), fp, indent=2)
cbrkit.dumpers.file(result.as_dict(), output_path)


@app.command()
Expand All @@ -103,8 +100,7 @@ def cycle(
result = cbrkit.cycle.apply_queries(casebase, queries, retrievers, reusers)

if output_path:
with output_path.with_suffix(".json").open("w") as fp:
json.dump(result.as_dict(), fp, indent=2)
cbrkit.dumpers.file(result.as_dict(), output_path)


@app.command()
Expand Down Expand Up @@ -132,8 +128,7 @@ def synthesis(
)

if output_path:
with output_path.with_suffix(".json").open("w") as fp:
json.dump(synthesis_result.as_dict(), fp, indent=2)
cbrkit.dumpers.file(synthesis_result.as_dict(), output_path)


@app.command()
Expand Down

0 comments on commit 3268d86

Please sign in to comment.