Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to output json format reports #768

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Next Release
------------
* Replace ``goodtables`` with ``pandera`` for data validation. This change is not
100% backwards compatible, although most data tables should be unaffected.
* Add option to output json report files.

0.16.1 (2023-11-21)
-------------------
Expand Down
11 changes: 11 additions & 0 deletions src/memote/suite/cli/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def report():
show_default=True,
help="Path for the HTML report output.",
)
@click.option(
"--json",
is_flag=True,
help="Flag to generate a json report file with the same base filename as the html report.",
)
@click.option(
"--pytest-args",
"-a",
Expand Down Expand Up @@ -129,6 +134,7 @@ def report():
def snapshot(
model,
filename,
json,
pytest_args,
exclusive,
skip,
Expand Down Expand Up @@ -177,6 +183,11 @@ def snapshot(
with open(filename, "w", encoding="utf-8") as file_handle:
LOGGER.info("Writing snapshot report to '%s'.", filename)
file_handle.write(api.snapshot_report(results, config))
if json:
filename = filename[:-4] + "json"
with open(filename, "w", encoding="utf-8") as file_handle:
LOGGER.info("Writing additional snapshot report to '%s'.", filename)
file_handle.write(api.snapshot_report(results, config, False))


@report.command(context_settings=CONTEXT_SETTINGS)
Expand Down
Loading