Skip to content

Commit

Permalink
[ENHANCEMENT] Enhance data doc to show data asset name in overview bl…
Browse files Browse the repository at this point in the history
…ock (#1952)

* enhance data doc to show data asset name in overview block #1804

* Update test, only get data_asset_name if exist

* Update fixture to match the new template

* update fixture
  • Loading branch information
noklam authored Oct 5, 2020
1 parent 9f8670f commit 7f95536
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
7 changes: 6 additions & 1 deletion great_expectations/render/renderer/page_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ def _render_validation_header(cls, validation_results):
expectation_suite_path = (
os.path.join(*expectation_suite_path_components) + ".html"
)
data_asset_name = (
validation_results.meta["batch_kwargs"].get("data_asset_name")
)
if success:
success = "Succeeded"
html_success_icon = (
Expand Down Expand Up @@ -262,9 +265,11 @@ def _render_validation_header(cls, validation_results):
**{
"content_block_type": "string_template",
"string_template": {
"template": "${suite_title} ${expectation_suite_name}\n${status_title} ${html_success_icon} ${success}",
"template": "${suite_title} ${expectation_suite_name}\n ${data_asset} ${data_asset_name}\n ${status_title} ${html_success_icon} ${success}",
"params": {
"suite_title": "Expectation Suite:",
"data_asset": "Data asset:",
"data_asset_name": data_asset_name,
"status_title": "Status:",
"expectation_suite_name": expectation_suite_name,
"success": success,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
"subheader": {
"content_block_type": "string_template",
"string_template": {
"template": "${suite_title} ${expectation_suite_name}\n${status_title} ${html_success_icon} ${success}",
"template": "${suite_title} ${expectation_suite_name}\n ${data_asset} ${data_asset_name}\n ${status_title} ${html_success_icon} ${success}",
"params": {
"suite_title": "Expectation Suite:",
"data_asset": "Data asset:",
"data_asset_name": null,
"status_title": "Status:",
"expectation_suite_name": "default",
"success": "Failed",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
"subheader": {
"content_block_type": "string_template",
"string_template": {
"template": "${suite_title} ${expectation_suite_name}\n${status_title} ${html_success_icon} ${success}",
"template": "${suite_title} ${expectation_suite_name}\n ${data_asset} ${data_asset_name}\n ${status_title} ${html_success_icon} ${success}",
"params": {
"suite_title": "Expectation Suite:",
"data_asset": "Data asset:",
"data_asset_name": null,
"status_title": "Status:",
"expectation_suite_name": "default",
"success": "Failed",
Expand Down Expand Up @@ -4715,4 +4717,4 @@
"batch_kwargs": {
"ge_batch_id": "f499679e-6c5e-11ea-8d20-acde48001122"
}
}
}
4 changes: 4 additions & 0 deletions tests/render/test_default_markdown_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def test_snapshot_render_section_page_with_fixture_data(validation_operator_resu
## Overview
### **Expectation Suite:** **basic.warning**
**Data asset:** **None**
**Status:** **Failed**
Expand Down Expand Up @@ -293,6 +294,7 @@ def test_snapshot_render_section_page_with_fixture_data(validation_operator_resu
## Overview
### **Expectation Suite:** **basic.warning**
**Data asset:** **None**
**Status:** **Failed**
Expand Down Expand Up @@ -498,6 +500,7 @@ def test_render_section_page_with_fixture_data_multiple_validations(
## Overview
### **Expectation Suite:** **basic.warning**
**Dataasset:** **None**
**Status:** **Failed**
Expand Down Expand Up @@ -665,6 +668,7 @@ def test_render_section_page_with_fixture_data_multiple_validations(
## Overview
### **Expectation Suite:** **basic.warning**
**Dataasset:** **None**
**Status:** **Failed**
Expand Down
23 changes: 13 additions & 10 deletions tests/render/test_page_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,11 @@ def test_ValidationResultsPageRenderer_render_validation_header(
"subheader": {
"content_block_type": "string_template",
"string_template": {
"template": "${suite_title} ${expectation_suite_name}\n${status_title} ${html_success_icon} ${success}",
"template": "${suite_title} ${expectation_suite_name}\n ${data_asset} ${data_asset_name}\n ${status_title} ${html_success_icon} ${success}",
"params": {
"suite_title": "Expectation Suite:",
"data_asset": "Data asset:",
"data_asset_name": None,
"status_title": "Status:",
"expectation_suite_name": "default",
"success": "Failed",
Expand All @@ -236,8 +238,8 @@ def test_ValidationResultsPageRenderer_render_validation_header(
},
},
}

# print(validation_header)
import pprint
pprint.pprint(validation_header)
assert validation_header == expected_validation_header


Expand Down Expand Up @@ -512,10 +514,11 @@ def test_snapshot_ValidationResultsPageRenderer_render_with_run_info_at_end(
rendered_validation_results = validation_results_page_renderer.render(
titanic_profiled_evrs_1
).to_json_dict()
print(rendered_validation_results)
# with open(file_relative_path(__file__, "./fixtures/ValidationResultsPageRenderer_render_with_run_info_at_end.json"), "w") as f:
# json.dump(rendered_validation_results, f, indent=2)

import pprint
pprint.pprint(rendered_validation_results['sections'])
with open(file_relative_path(__file__, "./fixtures/ValidationResultsPageRenderer_render_with_run_info_at_end_nc.json"), "w") as f:
json.dump(rendered_validation_results, f, indent=2)
# pprint.pprint(ValidationResultsPageRenderer_render_with_run_info_at_end)
assert (
rendered_validation_results
== ValidationResultsPageRenderer_render_with_run_info_at_end
Expand All @@ -532,9 +535,9 @@ def test_snapshot_ValidationResultsPageRenderer_render_with_run_info_at_start(
rendered_validation_results = validation_results_page_renderer.render(
titanic_profiled_evrs_1
).to_json_dict()
print(rendered_validation_results)
# with open(file_relative_path(__file__, "./fixtures/ValidationResultsPageRenderer_render_with_run_info_at_start.json"), "w") as f:
# json.dump(rendered_validation_results, f, indent=2)
# print(rendered_validation_results)
with open(file_relative_path(__file__, "./fixtures/ValidationResultsPageRenderer_render_with_run_info_at_start_nc.json"), "w") as f:
json.dump(rendered_validation_results, f, indent=2)

assert (
rendered_validation_results
Expand Down

0 comments on commit 7f95536

Please sign in to comment.