Skip to content

Commit

Permalink
Merge branch 'develop' into f/GREAT-1314/batch_list
Browse files Browse the repository at this point in the history
  • Loading branch information
billdirks authored Nov 14, 2022
2 parents 2f62988 + 8b358d2 commit cba2fc5
Show file tree
Hide file tree
Showing 64 changed files with 479 additions and 570 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
4 changes: 1 addition & 3 deletions great_expectations/checkpoint/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
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 GeCloudRESTResource
from great_expectations.data_context.types.base import (
CheckpointConfig,
CheckpointValidationConfig,
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
2 changes: 1 addition & 1 deletion great_expectations/core/config_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def __init__(self, cloud_config: GeCloudConfig) -> None:
self._cloud_config = cloud_config

def get_values(self) -> Dict[str, str]:
from great_expectations.data_context.data_context.cloud_data_context import (
from great_expectations.data_context.cloud_constants import (
GECloudEnvironmentVariable,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class GEDependencies:
"requests",
"ruamel.yaml",
"scipy",
"termcolor",
"tqdm",
"typing-extensions",
"urllib3",
Expand Down
27 changes: 27 additions & 0 deletions great_expectations/data_context/cloud_constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
from enum import Enum

from typing_extensions import Final

CLOUD_DEFAULT_BASE_URL: Final[str] = "https://api.greatexpectations.io/"


class GECloudEnvironmentVariable(str, Enum):
BASE_URL = "GE_CLOUD_BASE_URL"
ORGANIZATION_ID = "GE_CLOUD_ORGANIZATION_ID"
ACCESS_TOKEN = "GE_CLOUD_ACCESS_TOKEN"


class GeCloudRESTResource(str, Enum):
BATCH = "batch"
CHECKPOINT = "checkpoint"
# Chetan - 20220811 - CONTRACT is deprecated by GX Cloud and is to be removed upon migration of E2E tests
CONTRACT = "contract"
DATASOURCE = "datasource"
DATA_ASSET = "data_asset"
DATA_CONTEXT = "data_context"
DATA_CONTEXT_VARIABLES = "data_context_variables"
EXPECTATION = "expectation"
EXPECTATION_SUITE = "expectation_suite"
EXPECTATION_VALIDATION_RESULT = "expectation_validation_result"
PROFILER = "profiler"
RENDERED_DATA_DOC = "rendered_data_doc"
# Chetan - 20220812 - SUITE_VALIDATION_RESULT is deprecated by GX Cloud and is to be removed upon migration of E2E tests
SUITE_VALIDATION_RESULT = "suite_validation_result"
VALIDATION_RESULT = "validation_result"
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
usage_statistics_enabled_method,
)
from great_expectations.data_asset import DataAsset
from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.data_context.cloud_data_context import (
CloudDataContext,
)
Expand All @@ -30,9 +31,6 @@
from great_expectations.data_context.data_context.file_data_context import (
FileDataContext,
)
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.templates import CONFIG_VARIABLES_TEMPLATE
from great_expectations.data_context.types.base import (
DataContextConfig,
Expand Down
16 changes: 5 additions & 11 deletions great_expectations/data_context/data_context/cloud_data_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import logging
import os
from enum import Enum
from typing import TYPE_CHECKING, Dict, List, Mapping, Optional, Union, cast

import requests
Expand All @@ -15,16 +14,17 @@
ConfigurationProvider,
)
from great_expectations.core.serializer import JsonConfigSerializer
from great_expectations.data_context.cloud_constants import CLOUD_DEFAULT_BASE_URL
from great_expectations.data_context.cloud_constants import (
CLOUD_DEFAULT_BASE_URL,
GECloudEnvironmentVariable,
GeCloudRESTResource,
)
from great_expectations.data_context.data_context.abstract_data_context import (
AbstractDataContext,
)
from great_expectations.data_context.data_context_variables import (
CloudDataContextVariables,
)
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.types.base import (
DEFAULT_USAGE_STATISTICS_URL,
DataContextConfig,
Expand All @@ -43,12 +43,6 @@
logger = logging.getLogger(__name__)


class GECloudEnvironmentVariable(str, Enum):
BASE_URL = "GE_CLOUD_BASE_URL"
ORGANIZATION_ID = "GE_CLOUD_ORGANIZATION_ID"
ACCESS_TOKEN = "GE_CLOUD_ACCESS_TOKEN"


class CloudDataContext(AbstractDataContext):
"""
Subclass of AbstractDataContext that contains functionality necessary to hydrate state from cloud
Expand Down
4 changes: 1 addition & 3 deletions great_expectations/data_context/data_context_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,10 @@ def __post_init__(self) -> None:
)

def _init_store(self) -> DataContextStore:
from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.store.data_context_store import (
DataContextStore,
)
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)

store_backend: dict = {
"class_name": "GeCloudStoreBackend",
Expand Down
2 changes: 1 addition & 1 deletion great_expectations/data_context/migrator/cloud_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from great_expectations.core.http import create_session
from great_expectations.core.usage_statistics.events import UsageStatsEvents
from great_expectations.core.usage_statistics.usage_statistics import send_usage_message
from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.data_context.base_data_context import (
BaseDataContext,
)
Expand All @@ -41,7 +42,6 @@
ConfigurationBundleSchema,
)
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
GeCloudStoreBackend,
construct_json_payload,
construct_url,
Expand Down
4 changes: 1 addition & 3 deletions great_expectations/data_context/store/checkpoint_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

import great_expectations.exceptions as ge_exceptions
from great_expectations.core.data_context_key import DataContextKey
from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.store import ConfigurationStore
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.types.base import (
CheckpointConfig,
DataContextConfigDefaults,
Expand Down
4 changes: 1 addition & 3 deletions great_expectations/data_context/store/configuration_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from ruamel.yaml.comments import CommentedMap

import great_expectations.exceptions as ge_exceptions
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.store.store import Store
from great_expectations.data_context.store.tuple_store_backend import TupleStoreBackend
from great_expectations.data_context.types.base import BaseYamlConfig
Expand Down
4 changes: 1 addition & 3 deletions great_expectations/data_context/store/expectations_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

from great_expectations.core import ExpectationSuite
from great_expectations.core.expectation_suite import ExpectationSuiteSchema
from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.store.database_store_backend import (
DatabaseStoreBackend,
)
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.store.store import Store
from great_expectations.data_context.store.tuple_store_backend import TupleStoreBackend
from great_expectations.data_context.types.resource_identifiers import (
Expand Down
25 changes: 4 additions & 21 deletions great_expectations/data_context/store/ge_cloud_store_backend.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import json
import logging
from abc import ABCMeta
from enum import Enum
from typing import Any, Dict, List, Optional, Set, Tuple, Union, cast
from urllib.parse import urljoin

import requests

from great_expectations.core.http import create_session
from great_expectations.data_context.cloud_constants import CLOUD_DEFAULT_BASE_URL
from great_expectations.data_context.cloud_constants import (
CLOUD_DEFAULT_BASE_URL,
GeCloudRESTResource,
)
from great_expectations.data_context.store.store_backend import StoreBackend
from great_expectations.data_context.types.refs import GeCloudResourceRef
from great_expectations.data_context.types.resource_identifiers import GeCloudIdentifier
Expand Down Expand Up @@ -107,25 +109,6 @@ def get_user_friendly_error_message(
return " ".join(support_message)


class GeCloudRESTResource(str, Enum):
BATCH = "batch"
CHECKPOINT = "checkpoint"
# Chetan - 20220811 - CONTRACT is deprecated by GX Cloud and is to be removed upon migration of E2E tests
CONTRACT = "contract"
DATASOURCE = "datasource"
DATA_ASSET = "data_asset"
DATA_CONTEXT = "data_context"
DATA_CONTEXT_VARIABLES = "data_context_variables"
EXPECTATION = "expectation"
EXPECTATION_SUITE = "expectation_suite"
EXPECTATION_VALIDATION_RESULT = "expectation_validation_result"
PROFILER = "profiler"
RENDERED_DATA_DOC = "rendered_data_doc"
# Chetan - 20220812 - SUITE_VALIDATION_RESULT is deprecated by GX Cloud and is to be removed upon migration of E2E tests
SUITE_VALIDATION_RESULT = "suite_validation_result"
VALIDATION_RESULT = "validation_result"


class GeCloudStoreBackend(StoreBackend, metaclass=ABCMeta):
PAYLOAD_ATTRIBUTES_KEYS: Dict[GeCloudRESTResource, str] = {
GeCloudRESTResource.CHECKPOINT: "checkpoint_config",
Expand Down
4 changes: 1 addition & 3 deletions great_expectations/data_context/store/profiler_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
import uuid
from typing import Union

from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.store.configuration_store import ConfigurationStore
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.types.resource_identifiers import (
ConfigurationIdentifier,
GeCloudIdentifier,
Expand Down
4 changes: 1 addition & 3 deletions great_expectations/data_context/store/validations_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
ExpectationSuiteValidationResult,
ExpectationSuiteValidationResultSchema,
)
from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.store.database_store_backend import (
DatabaseStoreBackend,
)
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.store.store import Store
from great_expectations.data_context.store.tuple_store_backend import TupleStoreBackend
from great_expectations.data_context.types.resource_identifiers import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
from great_expectations.exceptions import DataContextError, InvalidDataContextKeyError

if TYPE_CHECKING:
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.cloud_constants import GeCloudRESTResource

logger = logging.getLogger(__name__)

Expand Down
Loading

0 comments on commit cba2fc5

Please sign in to comment.