-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[BUGFIX] Show FDS Asset name in DataDocs #9950
Changes from 14 commits
e150f56
6281932
8b2819d
4d2f042
5e47acd
23e4e00
109f9dd
330cb9e
d24c81a
c92ff81
1b7a634
1274764
a0375d3
0ded028
c2e5904
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
import os | ||
import pathlib | ||
import traceback | ||
import urllib | ||
from collections import OrderedDict | ||
from typing import Any, List, Optional, Tuple | ||
from typing import TYPE_CHECKING, Any, List, Optional, Tuple | ||
|
||
from great_expectations import exceptions | ||
from great_expectations.core import ExpectationSuite | ||
|
@@ -23,6 +25,12 @@ | |
from great_expectations.data_context.util import instantiate_class_from_config | ||
from great_expectations.render.util import resource_key_passes_run_name_filter | ||
|
||
if TYPE_CHECKING: | ||
from great_expectations.core.expectation_validation_result import ( | ||
ExpectationValidationResult, | ||
) | ||
from great_expectations.data_context import AbstractDataContext | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
FALSEY_YAML_STRINGS = [ | ||
|
@@ -114,7 +122,7 @@ class SiteBuilder: | |
|
||
def __init__( # noqa: C901, PLR0912, PLR0913 | ||
self, | ||
data_context, | ||
data_context: AbstractDataContext, | ||
store_backend, | ||
site_name=None, | ||
site_index_builder=None, | ||
|
@@ -347,7 +355,7 @@ class DefaultSiteSectionBuilder: | |
def __init__( # noqa: PLR0913 | ||
self, | ||
name, | ||
data_context, | ||
data_context: AbstractDataContext, | ||
target_store, | ||
source_store_name, | ||
custom_styles_directory=None, | ||
|
@@ -516,7 +524,7 @@ def __init__( # noqa: PLR0913 | |
self, | ||
name, | ||
site_name, | ||
data_context, | ||
data_context: AbstractDataContext, | ||
target_store, | ||
site_section_builders_config, | ||
custom_styles_directory=None, | ||
|
@@ -904,8 +912,7 @@ def _add_profiling_to_index_links( | |
run_id=profiling_result_key.run_id, | ||
run_time=profiling_result_key.run_id.run_time, | ||
run_name=profiling_result_key.run_id.run_name, | ||
asset_name=batch_kwargs.get("data_asset_name") | ||
or batch_spec.get("data_asset_name"), | ||
asset_name=_resolve_asset_name(validation), | ||
batch_kwargs=batch_kwargs, | ||
batch_spec=batch_spec, | ||
) | ||
|
@@ -961,8 +968,7 @@ def _add_validations_to_index_links( | |
validation_success=validation_success, | ||
run_time=validation_result_key.run_id.run_time, | ||
run_name=validation_result_key.run_id.run_name, | ||
asset_name=batch_kwargs.get("data_asset_name") | ||
or batch_spec.get("data_asset_name"), | ||
asset_name=_resolve_asset_name(validation), | ||
batch_kwargs=batch_kwargs, | ||
batch_spec=batch_spec, | ||
) | ||
|
@@ -971,6 +977,25 @@ def _add_validations_to_index_links( | |
logger.warning(error_msg) | ||
|
||
|
||
def _resolve_asset_name(validation_results: ExpectationValidationResult) -> str | None: | ||
""" | ||
Resolve the asset name from the validation results meta data. | ||
FDS does not store data_asset_name in batch_kwargs or batch_spec and it must be | ||
pulled from the active batch definition. | ||
""" | ||
Comment on lines
+980
to
+985
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @morphatic Thanks so much for the detailed issue description. Would you like me to make you a CoAuthor on this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Glad it helped! I would not complain about being listed as a co-author. Thank you for asking! |
||
batch_kwargs = validation_results.meta.get("batch_kwargs", {}) | ||
batch_spec = validation_results.meta.get("batch_spec", {}) | ||
Comment on lines
+986
to
+987
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of both of these may be going away in V1 but |
||
|
||
asset_name = batch_kwargs.get("data_asset_name") or batch_spec.get( | ||
"data_asset_name" | ||
) | ||
if asset_name: | ||
return asset_name | ||
# FDS does not store data_asset_name in batch_kwargs or batch_spec | ||
active_batch = validation_results.meta.get("active_batch_definition", {}) | ||
return active_batch.get("data_asset_name") | ||
|
||
|
||
class CallToActionButton: | ||
def __init__(self, title, link) -> None: | ||
self.title = title | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make the return type a union with a dict so you don't have to ignore this here? This may cause you to assert at the call sites though.