Skip to content

Commit

Permalink
Merge branch 'develop' into f/dx-67/sql-pk-feature
Browse files Browse the repository at this point in the history
* develop:
  [MAINTENANCE] Update column_reflection_fallback to also use schema name for Trino (#6350)
  [MAINTENANCE] Misc cleanup of GX Cloud helpers (#6352)
  [MAINTENANCE] Pin `mypy` to `0.990` (#6361)
  Subject: Support to include ID/PK in validation result for each row t… (#5876)
  [MAINTENANCE] Fix computed metrics type hint in ExecutionEngine.resolve_metrics() method (#6347)
  [MAINTENANCE] Refactor `usage_stats_opt_out` method in DataContext (#5339)
  Zep PostgresDatasource returns a list of batches. (#6341)
  [DOCS] Add `yarn snippet-check` command (#6351)
  [MAINTENANCE] Refactor out `termcolor` dependency (#6348)
  [MAINTENANCE] Move Cloud-specific enums to `cloud_constants.py` (#6349)
  • Loading branch information
Will Shin committed Nov 15, 2022
2 parents 0768f15 + f320054 commit 79b2dea
Show file tree
Hide file tree
Showing 114 changed files with 1,487 additions and 1,461 deletions.
1 change: 0 additions & 1 deletion docs_rtd/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
sybil==1.4.0
termcolor==1.1.0
terminado==0.8.3
testpath==0.4.4
toml==0.10.1
Expand Down
52 changes: 26 additions & 26 deletions great_expectations/checkpoint/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from urllib.parse import urljoin

from great_expectations.core import ExpectationSuiteValidationResult
from great_expectations.data_context.types.refs import GeCloudResourceRef
from great_expectations.data_context.types.refs import GXCloudResourceRef

try:
import pypd
Expand All @@ -28,7 +28,7 @@
from great_expectations.data_context.store.metric_store import MetricStore
from great_expectations.data_context.types.resource_identifiers import (
ExpectationSuiteIdentifier,
GeCloudIdentifier,
GXCloudIdentifier,
ValidationResultIdentifier,
)
from great_expectations.data_context.util import instantiate_class_from_config
Expand All @@ -52,7 +52,7 @@ def run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset,
expectation_suite_identifier: Optional[ExpectationSuiteIdentifier] = None,
Expand Down Expand Up @@ -82,7 +82,7 @@ def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset,
expectation_suite_identifier=None,
Expand All @@ -102,7 +102,7 @@ def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset,
expectation_suite_identifier=None,
Expand Down Expand Up @@ -196,7 +196,7 @@ def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset=None,
payload=None,
Expand All @@ -213,7 +213,7 @@ def _run(

if not isinstance(
validation_result_suite_identifier,
(ValidationResultIdentifier, GeCloudIdentifier),
(ValidationResultIdentifier, GXCloudIdentifier),
):
raise TypeError(
"validation_result_suite_id must be of type ValidationResultIdentifier or GeCloudIdentifier, "
Expand Down Expand Up @@ -301,7 +301,7 @@ def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset=None,
payload=None,
Expand All @@ -318,7 +318,7 @@ def _run(

if not isinstance(
validation_result_suite_identifier,
(ValidationResultIdentifier, GeCloudIdentifier),
(ValidationResultIdentifier, GXCloudIdentifier),
):
raise TypeError(
"validation_result_suite_id must be of type ValidationResultIdentifier or GeCloudIdentifier, "
Expand Down Expand Up @@ -422,7 +422,7 @@ def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset=None,
payload=None,
Expand All @@ -439,7 +439,7 @@ def _run(

if not isinstance(
validation_result_suite_identifier,
(ValidationResultIdentifier, GeCloudIdentifier),
(ValidationResultIdentifier, GXCloudIdentifier),
):
raise TypeError(
"validation_result_suite_id must be of type ValidationResultIdentifier or GeCloudIdentifier, "
Expand Down Expand Up @@ -539,7 +539,7 @@ def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset=None,
payload=None,
Expand All @@ -556,7 +556,7 @@ def _run(

if not isinstance(
validation_result_suite_identifier,
(ValidationResultIdentifier, GeCloudIdentifier),
(ValidationResultIdentifier, GXCloudIdentifier),
):
raise TypeError(
"validation_result_suite_id must be of type ValidationResultIdentifier or GeCloudIdentifier, "
Expand Down Expand Up @@ -698,7 +698,7 @@ def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset=None,
payload=None,
Expand All @@ -715,7 +715,7 @@ def _run(

if not isinstance(
validation_result_suite_identifier,
(ValidationResultIdentifier, GeCloudIdentifier),
(ValidationResultIdentifier, GXCloudIdentifier),
):
raise TypeError(
"validation_result_suite_id must be of type ValidationResultIdentifier or GeCloudIdentifier, "
Expand Down Expand Up @@ -798,7 +798,7 @@ def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset,
payload=None,
Expand All @@ -815,7 +815,7 @@ def _run(

if not isinstance(
validation_result_suite_identifier,
(ValidationResultIdentifier, GeCloudIdentifier),
(ValidationResultIdentifier, GXCloudIdentifier),
):
raise TypeError(
"validation_result_id must be of type ValidationResultIdentifier or GeCloudIdentifier, not {}".format(
Expand All @@ -840,7 +840,7 @@ def _run(
expectation_suite_id=expectation_suite_ge_cloud_id,
)
if self.data_context.ge_cloud_mode:
return_val: GeCloudResourceRef
return_val: GXCloudResourceRef
new_ge_cloud_id = return_val.ge_cloud_id
validation_result_suite_identifier.ge_cloud_id = new_ge_cloud_id

Expand Down Expand Up @@ -885,7 +885,7 @@ def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset,
payload=None,
Expand All @@ -902,7 +902,7 @@ def _run(

if not isinstance(
validation_result_suite_identifier,
(ValidationResultIdentifier, GeCloudIdentifier),
(ValidationResultIdentifier, GXCloudIdentifier),
):
raise TypeError(
"validation_result_id must be of type ValidationResultIdentifier or GeCloudIdentifier, not {}".format(
Expand Down Expand Up @@ -968,7 +968,7 @@ def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset,
payload=None,
Expand All @@ -985,7 +985,7 @@ def _run(

if not isinstance(
validation_result_suite_identifier,
(ValidationResultIdentifier, GeCloudIdentifier),
(ValidationResultIdentifier, GXCloudIdentifier),
):
raise TypeError(
"validation_result_id must be of type ValidationResultIdentifier or GeCloudIdentifier, not {}".format(
Expand Down Expand Up @@ -1047,7 +1047,7 @@ def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: Union[
ValidationResultIdentifier, GeCloudIdentifier
ValidationResultIdentifier, GXCloudIdentifier
],
data_asset,
payload=None,
Expand All @@ -1064,7 +1064,7 @@ def _run(

if not isinstance(
validation_result_suite_identifier,
(ValidationResultIdentifier, GeCloudIdentifier),
(ValidationResultIdentifier, GXCloudIdentifier),
):
raise TypeError(
"validation_result_id must be of type ValidationResultIdentifier or GeCloudIdentifier, not {}".format(
Expand Down Expand Up @@ -1119,7 +1119,7 @@ def __init__(
def _run(
self,
validation_result_suite: ExpectationSuiteValidationResult,
validation_result_suite_identifier: GeCloudIdentifier,
validation_result_suite_identifier: GXCloudIdentifier,
data_asset=None,
payload: Optional[Dict] = None,
expectation_suite_identifier=None,
Expand All @@ -1136,7 +1136,7 @@ def _run(
return Exception(
"CloudNotificationActions can only be used in GE Cloud Mode."
)
if not isinstance(validation_result_suite_identifier, GeCloudIdentifier):
if not isinstance(validation_result_suite_identifier, GXCloudIdentifier):
raise TypeError(
"validation_result_id must be of type GeCloudIdentifier, not {}".format(
type(validation_result_suite_identifier)
Expand Down
10 changes: 4 additions & 6 deletions great_expectations/checkpoint/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@
usage_statistics_enabled_method,
)
from great_expectations.data_asset import DataAsset
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.cloud_constants import GXCloudRESTResource
from great_expectations.data_context.types.base import (
CheckpointConfig,
CheckpointValidationConfig,
)
from great_expectations.data_context.types.resource_identifiers import GeCloudIdentifier
from great_expectations.data_context.types.resource_identifiers import GXCloudIdentifier
from great_expectations.data_context.util import (
instantiate_class_from_config,
substitute_all_config_variables,
Expand Down Expand Up @@ -398,8 +396,8 @@ def _run_validation(
)
checkpoint_identifier = None
if self.data_context.ge_cloud_mode:
checkpoint_identifier = GeCloudIdentifier(
resource_type=GeCloudRESTResource.CHECKPOINT,
checkpoint_identifier = GXCloudIdentifier(
resource_type=GXCloudRESTResource.CHECKPOINT,
ge_cloud_id=str(self.ge_cloud_id),
)

Expand Down
40 changes: 19 additions & 21 deletions great_expectations/cli/pretty_printing.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
import re
import sys
from typing import List, Optional
from typing import List, Optional, Tuple

from termcolor import colored
import click
from typing_extensions import Final

SUPPORTED_CLI_COLORS: Final[Tuple[str, ...]] = (
"blue",
"cyan",
"green",
"yellow",
"red",
)


def cli_message(string: str) -> None:
print(cli_colorize_string(string))


def cli_colorize_string(string: str) -> str:
# the DOTALL flag means that `.` includes newlines for multiline comments inside these tags
flags = re.DOTALL
mod_string = re.sub(
"<blue>(.*?)</blue>", colored(r"\g<1>", "blue"), string, flags=flags
)
mod_string = re.sub(
"<cyan>(.*?)</cyan>", colored(r"\g<1>", "cyan"), mod_string, flags=flags
)
mod_string = re.sub(
"<green>(.*?)</green>", colored(r"\g<1>", "green"), mod_string, flags=flags
)
mod_string = re.sub(
"<yellow>(.*?)</yellow>", colored(r"\g<1>", "yellow"), mod_string, flags=flags
)
mod_string = re.sub(
"<red>(.*?)</red>", colored(r"\g<1>", "red"), mod_string, flags=flags
)

return colored(mod_string)
for color in SUPPORTED_CLI_COLORS:
string = re.sub(
f"<{color}>(.*?)</{color}>",
click.style(r"\g<1>", fg=color),
string,
flags=re.DOTALL, # the DOTALL flag means that `.` includes newlines for multiline comments inside these tags
)
return string


def display_not_implemented_message_and_exit() -> None:
Expand Down
46 changes: 20 additions & 26 deletions great_expectations/cli/v012/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,41 @@
import re
import sys
from types import ModuleType
from typing import Optional
from typing import Optional, Tuple

import click
import pkg_resources
from pkg_resources import Distribution, WorkingSet
from typing_extensions import Final

from great_expectations.cli.v012 import toolkit
from great_expectations.cli.v012.python_subprocess import (
execute_shell_command_with_progress_polling,
)
from great_expectations.util import import_library_module, is_library_loadable

try:
from termcolor import colored
except ImportError:
colored = None
SUPPORTED_CLI_COLORS: Final[Tuple[str, ...]] = (
"blue",
"cyan",
"green",
"yellow",
"red",
)


def cli_message(string) -> None:
def cli_message(string: str) -> None:
print(cli_colorize_string(string))


def cli_colorize_string(string):
# the DOTALL flag means that `.` includes newlines for multiline comments inside these tags
flags = re.DOTALL
mod_string = re.sub(
"<blue>(.*?)</blue>", colored(r"\g<1>", "blue"), string, flags=flags
)
mod_string = re.sub(
"<cyan>(.*?)</cyan>", colored(r"\g<1>", "cyan"), mod_string, flags=flags
)
mod_string = re.sub(
"<green>(.*?)</green>", colored(r"\g<1>", "green"), mod_string, flags=flags
)
mod_string = re.sub(
"<yellow>(.*?)</yellow>", colored(r"\g<1>", "yellow"), mod_string, flags=flags
)
mod_string = re.sub(
"<red>(.*?)</red>", colored(r"\g<1>", "red"), mod_string, flags=flags
)

return colored(mod_string)
def cli_colorize_string(string: str) -> str:
for color in SUPPORTED_CLI_COLORS:
string = re.sub(
f"<{color}>(.*?)</{color}>",
click.style(r"\g<1>", fg=color),
string,
flags=re.DOTALL, # the DOTALL flag means that `.` includes newlines for multiline comments inside these tags
)
return string


def cli_message_list(string_list, list_intro_string=None) -> None:
Expand Down
Loading

0 comments on commit 79b2dea

Please sign in to comment.