Skip to content

Commit

Permalink
feat(cli): report using both area and trace names
Browse files Browse the repository at this point in the history
  • Loading branch information
nialov committed Sep 6, 2023
1 parent 370741b commit 08ebf47
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ def test_all_cli(ready_tracerepository: Path):

# Make sure pandera error was caught
assert "Reported" in validate_result.stdout
assert "kb" in validate_result.stdout
assert "traces" in validate_result.stdout
assert "area" in validate_result.stdout
assert "html" in validate_result.stdout
assert reports_path.exists()
assert len(list(reports_path.glob("*.html"))) > 0
Expand Down
1 change: 1 addition & 0 deletions tracerepo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def validate(
pandera_report=pandera_report,
report_directory=report_directory,
area_name=update_tuple.area_name,
traces_name=update_tuple.traces_path.stem,
)
console.print(str_report)

Expand Down
9 changes: 6 additions & 3 deletions tracerepo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,17 +349,20 @@ def filename_friendly_datetime_string() -> str:


def report_pandera_errors(
pandera_report: pd.DataFrame, report_directory: Path, area_name: str
pandera_report: pd.DataFrame,
report_directory: Path,
area_name: str,
traces_name: str,
) -> str:
"""
Report pandera errors as html files saved to a reports directory.
"""
report_directory.mkdir(exist_ok=True)
current_time = filename_friendly_datetime_string()
report_name = f"{area_name}_report_{current_time}.html"
report_name = f"{area_name}_{traces_name}_report_{current_time}.html"
report_path = report_directory / report_name
pandera_report.to_html(report_path)
return f"Reported {area_name} traces pandera errors to {report_path}."
return f"Reported pandera errors to {report_path}."


def otherwise_valid(update_tuple: UpdateTuple) -> bool:
Expand Down

0 comments on commit 08ebf47

Please sign in to comment.