Skip to content
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
2 changes: 1 addition & 1 deletion great_expectations/compatibility/pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
try:
import pyarrow
except ImportError:
pyarrow = PYARROW_NOT_IMPORTED
pyarrow = PYARROW_NOT_IMPORTED # type: ignore[assignment]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import logging
import traceback
import warnings
from copy import deepcopy
from typing import TYPE_CHECKING, Callable

Expand Down Expand Up @@ -90,10 +89,6 @@ def _get_content_block_fn( # noqa: C901 # FIXME CoP
)

expectation_string_fn = content_block_fn
if expectation_string_fn is None:
expectation_string_fn = cls._get_legacy_v2_api_style_expectation_string_fn(
expectation_type
)
if expectation_string_fn is None:
expectation_string_fn = cls._missing_content_block_fn

Expand Down Expand Up @@ -172,11 +167,7 @@ def row_generator_fn( # noqa: C901 # FIXME CoP
renderer_type=LegacyDiagnosticRendererType.OBSERVED_VALUE,
)
observed_value = [
observed_value_renderer[1](result=result)
if observed_value_renderer
else (
cls._get_legacy_v2_api_observed_value(expectation_string_fn, result) or "--"
)
observed_value_renderer[1](result=result) if observed_value_renderer else "--"
]
except Exception as e:
exception_traceback = traceback.format_exc()
Expand Down Expand Up @@ -206,43 +197,3 @@ def row_generator_fn( # noqa: C901 # FIXME CoP
return output_row

return row_generator_fn

@classmethod
def _get_legacy_v2_api_style_expectation_string_fn(cls, expectation_type):
legacy_expectation_string_fn = getattr(cls, expectation_type, None)
if legacy_expectation_string_fn is None:
# With the V2 API, expectation rendering was implemented by defining a method with the same name as the expectation. # noqa: E501 # FIXME CoP
# If no legacy rendering is present, return None.
return None

# deprecated-v0.13.28
warnings.warn(
"V2 API style custom rendering is deprecated as of v0.13.28 and is not fully supported anymore; " # noqa: E501 # FIXME CoP
"As it will be removed in v0.16, please transition to V3 API and associated rendering style", # noqa: E501 # FIXME CoP
DeprecationWarning,
)

def expectation_string_fn_with_legacy_translation(
configuration: ExpectationConfiguration, runtime_configuration: dict
):
if runtime_configuration is None:
runtime_configuration = {}

# With the V2 API, the expectation string function had a different signature; the below translates from the new signature to the legacy signature. # noqa: E501 # FIXME CoP
return legacy_expectation_string_fn(
expectation=configuration,
styling=runtime_configuration.get("styling", None),
include_column_name=runtime_configuration.get("include_column_name", True),
)

return expectation_string_fn_with_legacy_translation

@staticmethod
def _get_legacy_v2_api_observed_value(expectation_string_fn, result):
if expectation_string_fn.__name__ != "expectation_string_fn_with_legacy_translation":
# If legacy V2 API style rendering is used, "expectation_string_fn" will be the method defined in the above "_get_legacy_v2_api_style_expectation_string_fn". # noqa: E501 # FIXME CoP
# If this isn't the case, return None, so we don't do any legacy logic.
return None

# With V2 API style rendering, the result had an "observed_value" entry that could be rendered. # noqa: E501 # FIXME CoP
return result["result"].get("observed_value")
Original file line number Diff line number Diff line change
Expand Up @@ -485,97 +485,6 @@ def test_ValidationResultsTableContentBlockRenderer_get_content_block_fn(evr_suc
assert content_block_fn_output == content_block_fn_expected_output


@pytest.mark.filterwarnings("ignore:V2 API style custom rendering*:DeprecationWarning")
def test_ValidationResultsTableContentBlockRenderer_get_content_block_fn_with_v2_api_style_custom_rendering(): # noqa: E501 # FIXME CoP
"""Test backwards support for custom expectation rendering with the V2 API as described at
https://docs.greatexpectations.io/en/latest/reference/spare_parts/data_docs_reference.html#customizing-data-docs.
"""

custom_expectation_template = "custom_expectation_template"
custom_expectation_observed_value = "custom_expectation_observed_value"

class ValidationResultsTableContentBlockRendererWithV2ApiStyleCustomExpectations(
ValidationResultsTableContentBlockRenderer
):
@classmethod
def expect_custom_expectation_written_in_v2_api_style(
cls, expectation, styling=None, include_column_name: bool = True
):
return [
RenderedStringTemplateContent(
content_block_type="string_template",
string_template={
"template": custom_expectation_template,
"params": expectation.kwargs,
"styling": styling,
},
)
]

evr = ExpectationValidationResult(
success=True,
result={
"observed_value": custom_expectation_observed_value,
},
exception_info={
"raised_exception": False,
"exception_message": None,
"exception_traceback": None,
},
expectation_config=ExpectationConfiguration(
type="expect_custom_expectation",
kwargs={"column": "a_column_name", "result_format": "SUMMARY"},
),
)

content_block_fn = ValidationResultsTableContentBlockRendererWithV2ApiStyleCustomExpectations._get_content_block_fn( # noqa: E501 # FIXME CoP
"expect_custom_expectation_written_in_v2_api_style"
)
content_block_fn_output = content_block_fn(result=evr)

content_block_fn_expected_output = [
[
RenderedStringTemplateContent(
**{
"content_block_type": "string_template",
"string_template": {
"template": "$icon",
"params": {"icon": "", "markdown_status_icon": "✅"},
"styling": {
"params": {
"icon": {
"classes": [
"fas",
"fa-check-circle",
"text-success",
],
"tag": "i",
}
}
},
},
"styling": {"parent": {"classes": ["hide-succeeded-validation-target-child"]}},
}
),
RenderedStringTemplateContent(
**{
"content_block_type": "string_template",
"string_template": {
"template": custom_expectation_template,
"params": {
"column": "a_column_name",
"result_format": "SUMMARY",
},
"styling": None,
},
}
),
custom_expectation_observed_value,
]
]
assert content_block_fn_output == content_block_fn_expected_output


def test_ValidationResultsTableContentBlockRenderer_get_observed_value(evr_success):
evr_no_result_key = ExpectationValidationResult(
success=True,
Expand Down
Loading