Skip to content

Commit

Permalink
[MAINTENANCE] Move Cloud-specific enums to cloud_constants.py (#6349)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdkini authored Nov 14, 2022
1 parent 1669a8b commit 143a9ff
Show file tree
Hide file tree
Showing 31 changed files with 67 additions and 124 deletions.
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
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
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
4 changes: 1 addition & 3 deletions great_expectations/render/renderer/site_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import great_expectations.exceptions as exceptions
from great_expectations.core import ExpectationSuite
from great_expectations.core.util import nested_update
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.html_site_store import (
HtmlSiteStore,
SiteSectionIdentifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
determine_progress_bar_method_by_environment,
nested_update,
)
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.refs import GeCloudResourceRef
from great_expectations.data_context.types.resource_identifiers import (
ConfigurationIdentifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
from great_expectations.core.run_identifier import RunIdentifier
from great_expectations.data_asset import DataAsset
from great_expectations.data_asset.util import parse_result_format
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.resource_identifiers import (
ExpectationSuiteIdentifier,
GeCloudIdentifier,
Expand Down
4 changes: 1 addition & 3 deletions tests/actions/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

from great_expectations.core import ExpectationSuiteValidationResult, RunIdentifier
from great_expectations.data_context import BaseDataContext
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 DataContextConfig
from great_expectations.data_context.types.resource_identifiers import (
BatchIdentifier,
Expand Down
4 changes: 1 addition & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
)
from great_expectations.core.util import get_or_create_spark_application
from great_expectations.data_context import BaseDataContext, CloudDataContext
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.profiler_store import ProfilerStore
from great_expectations.data_context.types.base import (
AnonymizedUsageStatisticsConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pytest

from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.data_context.abstract_data_context import (
AbstractDataContext,
)
Expand All @@ -14,9 +15,6 @@
CloudDataContext,
)
from great_expectations.data_context.data_context.data_context import DataContext
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.types.base import (
CheckpointConfig,
DataContextConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import pytest

from great_expectations.core.expectation_suite import ExpectationSuite
from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.data_context.base_data_context import (
BaseDataContext,
)
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.types.base import DataContextConfig, GeCloudConfig
from great_expectations.data_context.types.resource_identifiers import GeCloudIdentifier
from great_expectations.exceptions.exceptions import DataContextError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
ExpectationValidationResult,
)
from great_expectations.core.batch import RuntimeBatchRequest
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.refs import GeCloudResourceRef
from great_expectations.render import RenderedAtomicContent
from great_expectations.validator.validator import Validator
Expand Down
4 changes: 1 addition & 3 deletions tests/data_context/cloud_data_context/test_profiler_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

import pytest

from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.data_context.base_data_context import (
BaseDataContext,
)
from great_expectations.data_context.data_context.data_context import DataContext
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.types.base import DataContextConfig, GeCloudConfig
from great_expectations.data_context.types.resource_identifiers import GeCloudIdentifier
from great_expectations.rule_based_profiler.config.base import (
Expand Down
4 changes: 1 addition & 3 deletions tests/data_context/migrator/test_cloud_migrator.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 import CloudMigrator
from great_expectations.core.usage_statistics.events import UsageStatsEvents
from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.migrator.cloud_migrator import MigrationResponse
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.types.base import AnonymizedUsageStatisticsConfig
from tests.data_context.migrator.conftest import StubBaseDataContext

Expand Down
4 changes: 1 addition & 3 deletions tests/data_context/store/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import pytest

from great_expectations.core.serializer import JsonConfigSerializer
from great_expectations.data_context.cloud_constants import GeCloudRESTResource
from great_expectations.data_context.store import DatasourceStore
from great_expectations.data_context.store.ge_cloud_store_backend import (
GeCloudRESTResource,
)
from great_expectations.data_context.types.base import datasourceConfigSchema


Expand Down
Loading

0 comments on commit 143a9ff

Please sign in to comment.