Skip to content

Commit

Permalink
[MAINTENANCE] Clean up GX error types (#10356)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdkini authored Sep 6, 2024
1 parent 72910d7 commit 7f4cd71
Show file tree
Hide file tree
Showing 25 changed files with 95 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from typing import TYPE_CHECKING, Iterable, List, Optional, Union

import great_expectations.exceptions as gx_exceptions
from great_expectations.core.domain import (
Domain,
SemanticDomainTypes,
)
from great_expectations.experimental.rule_based_profiler.domain_builder import ColumnDomainBuilder
from great_expectations.experimental.rule_based_profiler.exceptions import ProfilerExecutionError
from great_expectations.experimental.rule_based_profiler.helpers.util import (
build_domains_from_column_names,
get_parameter_value_and_validate_return_type,
Expand Down Expand Up @@ -141,14 +141,14 @@ def _get_domains(
)

if not (profile_report_column_names and table_column_names):
raise gx_exceptions.ProfilerExecutionError(
raise ProfilerExecutionError(
message=f"Error: List of available table columns in {self.__class__.__name__} must not be empty."
)

if not is_candidate_subset_of_target(
candidate=profile_report_column_names, target=table_column_names
):
raise gx_exceptions.ProfilerExecutionError(
raise ProfilerExecutionError(
message=f"Error: Some of profiled columns in {self.__class__.__name__} are not found in Batch table."
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from great_expectations.analytics.client import submit as submit_event
from great_expectations.analytics.config import ENV_CONFIG
from great_expectations.analytics.events import DataContextInitializedEvent
from great_expectations.compatibility import sqlalchemy
from great_expectations.compatibility.typing_extensions import override
from great_expectations.core import ExpectationSuite
from great_expectations.core.batch import (
Expand Down Expand Up @@ -88,13 +87,6 @@
from great_expectations.exceptions.exceptions import DataContextError
from great_expectations.validator.validator import Validator

SQLAlchemyError = sqlalchemy.SQLAlchemyError
if not SQLAlchemyError: # type: ignore[truthy-function]
# We'll redefine this error in code below to catch ProfilerError, which is caught above, so SA errors will # noqa: E501
# just fall through
SQLAlchemyError = gx_exceptions.ProfilerError # type: ignore[misc]


if TYPE_CHECKING:
from typing_extensions import TypeAlias

Expand Down
17 changes: 0 additions & 17 deletions great_expectations/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
from .exceptions import (
AmbiguousDataAssetNameError,
BatchDefinitionError,
BatchFilterError,
BatchKwargsError,
BatchSpecError,
CheckpointError,
CheckpointNotFoundError,
ClassInstantiationError,
ConfigNotFoundError,
DataAssistantError,
DataAssistantExecutionError,
DataAssistantResultExecutionError,
DatabaseConnectionError,
DataConnectorError,
DataContextError,
DataContextRequiredError,
DatasourceError,
Expand All @@ -32,37 +26,26 @@
GXCloudError,
InvalidBaseYamlConfigError,
InvalidBatchIdError,
InvalidBatchKwargsError,
InvalidBatchRequestError,
InvalidBatchSpecError,
InvalidCacheValueError,
InvalidCheckpointConfigError,
InvalidConfigError,
InvalidConfigurationYamlError,
InvalidConfigValueTypeError,
InvalidDataContextConfigError,
InvalidDataContextKeyError,
InvalidExpectationConfigurationError,
InvalidExpectationKwargsError,
InvalidKeyError,
InvalidMetricAccessorDomainKwargsKeyError,
InvalidTopLevelConfigKeyError,
InvalidValidationResultError,
MetricComputationError,
MetricError,
MetricProviderError,
MetricResolutionError,
MigrationError,
MissingConfigVariableError,
MissingDataContextError,
MissingTopLevelConfigKeyError,
ParserError,
PluginClassNotFoundError,
PluginModuleNotFoundError,
ProfilerConfigurationError,
ProfilerError,
ProfilerExecutionError,
ProfilerNotFoundError,
RenderingError,
SamplerError,
SorterError,
Expand Down
85 changes: 1 addition & 84 deletions great_expectations/exceptions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ class StoreBackendTransientError(StoreBackendError):
pass


class ParserError(GreatExpectationsError):
pass


class InvalidConfigurationYamlError(DataContextError):
pass

Expand All @@ -142,10 +138,6 @@ class InvalidTopLevelConfigKeyError(GreatExpectationsError):
pass


class MissingTopLevelConfigKeyError(GreatExpectationsValidationError):
pass


class RenderingError(GreatExpectationsError):
pass

Expand All @@ -170,14 +162,6 @@ class InvalidDataContextConfigError(InvalidBaseYamlConfigError):
pass


class InvalidCheckpointConfigError(InvalidBaseYamlConfigError):
pass


class InvalidBatchKwargsError(GreatExpectationsError):
pass


class InvalidBatchSpecError(GreatExpectationsError):
pass

Expand Down Expand Up @@ -225,42 +209,6 @@ class SuiteParameterError(GreatExpectationsError):
pass


class ProfilerError(GreatExpectationsError):
pass


class ProfilerConfigurationError(ProfilerError):
"""A configuration error for a "RuleBasedProfiler" class."""

pass


class ProfilerExecutionError(ProfilerError):
"""A runtime error for a "RuleBasedProfiler" class."""

pass


class ProfilerNotFoundError(ProfilerError):
pass


class DataAssistantError(ProfilerError):
pass


class DataAssistantExecutionError(DataAssistantError):
"""A runtime error for a "DataAssistant" class."""

pass


class DataAssistantResultExecutionError(DataAssistantError):
"""A runtime error for a "DataAssistantResult" class."""

pass


class InvalidConfigError(DataContextError):
def __init__(self, message) -> None:
self.message = message
Expand All @@ -276,13 +224,6 @@ def __init__(self, message, missing_config_variable=None) -> None:
super().__init__(self.message)


class AmbiguousDataAssetNameError(DataContextError):
def __init__(self, message, candidates=None) -> None:
self.message = message
self.candidates = candidates
super().__init__(self.message)


class StoreConfigurationError(DataContextError):
pass

Expand All @@ -299,10 +240,6 @@ class ExpectationNotFoundError(GreatExpectationsError):
pass


class InvalidValidationResultError(GreatExpectationsError):
pass


class GreatExpectationsTypeError(TypeError):
pass

Expand Down Expand Up @@ -429,13 +366,6 @@ def __init__(self, data_asset_name) -> None:
super().__init__(self.message)


class BatchKwargsError(DataContextError):
def __init__(self, message, batch_kwargs=None) -> None:
self.message = message
self.batch_kwargs = batch_kwargs
super().__init__(self.message)


class BatchDefinitionError(DataContextError):
def __init__(self, message) -> None:
self.message = message
Expand Down Expand Up @@ -480,16 +410,6 @@ def __init__(self, message: str) -> None:
super().__init__(self.message)


class InvalidConfigValueTypeError(DataContextError):
pass


class DataConnectorError(DataContextError):
def __init__(self, message) -> None:
self.message = message
super().__init__(self.message)


class ExecutionEngineError(DataContextError):
def __init__(self, message) -> None:
self.message = message
Expand Down Expand Up @@ -558,9 +478,6 @@ class GXCloudConfigurationError(GreatExpectationsError):
""" # noqa: E501


# Only used in tests
class DatabaseConnectionError(GreatExpectationsError):
"""Error connecting to a database including during an integration test."""


class MigrationError(GreatExpectationsError):
"""Error when using the migration tool."""
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
import json
from typing import TYPE_CHECKING, Any, ClassVar, List, Optional, Set, Union

import great_expectations.exceptions as gx_exceptions
from great_expectations.compatibility.typing_extensions import override
from great_expectations.core.batch import (
Batch,
BatchRequestBase,
batch_request_contains_batch_data,
get_batch_request_as_dict,
)
from great_expectations.experimental.rule_based_profiler.exceptions import (
ProfilerConfigurationError,
)
from great_expectations.types import SerializableDictDot, safe_deep_copy
from great_expectations.util import (
convert_to_json_serializable, # noqa: TID251
Expand Down Expand Up @@ -102,7 +104,7 @@ def set_batch_data(
)
)
if num_supplied_batch_specification_args > 1:
raise gx_exceptions.ProfilerConfigurationError( # noqa: TRY003
raise ProfilerConfigurationError( # noqa: TRY003
f'Please pass at most one of "batch_list" and "batch_request" arguments (you passed {num_supplied_batch_specification_args} arguments).' # noqa: E501
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
Union,
)

import great_expectations.exceptions as gx_exceptions
from great_expectations.compatibility.typing_extensions import override
from great_expectations.core.domain import Domain, SemanticDomainTypes
from great_expectations.core.metric_domain_types import MetricDomainTypes
from great_expectations.experimental.rule_based_profiler.domain_builder import ColumnDomainBuilder
from great_expectations.experimental.rule_based_profiler.exceptions import ProfilerExecutionError
from great_expectations.experimental.rule_based_profiler.helpers.cardinality_checker import (
AbsoluteCardinalityLimit,
CardinalityChecker,
Expand Down Expand Up @@ -308,7 +308,7 @@ def _get_domains(
)

if validator is None:
raise gx_exceptions.ProfilerExecutionError(
raise ProfilerExecutionError(
message=f"Error: Failed to obtain Validator {self.__class__.__name__}"
" (Validator is required for cardinality checks)."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
cast,
)

import great_expectations.exceptions as gx_exceptions
from great_expectations.compatibility.typing_extensions import override
from great_expectations.core.domain import Domain, SemanticDomainTypes
from great_expectations.core.metric_domain_types import MetricDomainTypes
from great_expectations.data_context.util import instantiate_class_from_config
from great_expectations.experimental.rule_based_profiler.domain_builder import DomainBuilder
from great_expectations.experimental.rule_based_profiler.exceptions import ProfilerExecutionError
from great_expectations.experimental.rule_based_profiler.helpers.util import (
build_domains_from_column_names,
get_parameter_value_and_validate_return_type,
Expand Down Expand Up @@ -263,7 +263,7 @@ def get_filtered_column_names( # noqa: C901

for column_name in filtered_column_names:
if column_name not in column_names:
raise gx_exceptions.ProfilerExecutionError(
raise ProfilerExecutionError(
message=f'Error: The column "{column_name}" in BatchData does not exist.'
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from typing import TYPE_CHECKING, ClassVar, Dict, List, Optional, Set, Union

import great_expectations.exceptions as gx_exceptions
from great_expectations.compatibility.typing_extensions import override
from great_expectations.core.domain import (
INFERRED_SEMANTIC_TYPE_KEY,
Expand All @@ -11,6 +10,7 @@
)
from great_expectations.core.metric_domain_types import MetricDomainTypes
from great_expectations.experimental.rule_based_profiler.domain_builder import ColumnDomainBuilder
from great_expectations.experimental.rule_based_profiler.exceptions import ProfilerExecutionError
from great_expectations.experimental.rule_based_profiler.parameter_container import (
ParameterContainer, # noqa: TCH001
)
Expand Down Expand Up @@ -94,7 +94,7 @@ def _get_domains(
if not (
effective_column_names and (len(effective_column_names) == 2) # noqa: PLR2004
):
raise gx_exceptions.ProfilerExecutionError(
raise ProfilerExecutionError(
message=f"""Error: Columns specified for {self.__class__.__name__} in sorted order must correspond to \
"column_A" and "column_B" (in this exact order).
""" # noqa: E501
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from typing import TYPE_CHECKING, ClassVar, Dict, List, Optional, Set, Union

import great_expectations.exceptions as gx_exceptions
from great_expectations.compatibility.typing_extensions import override
from great_expectations.core.domain import (
INFERRED_SEMANTIC_TYPE_KEY,
Expand All @@ -11,6 +10,7 @@
)
from great_expectations.core.metric_domain_types import MetricDomainTypes
from great_expectations.experimental.rule_based_profiler.domain_builder import ColumnDomainBuilder
from great_expectations.experimental.rule_based_profiler.exceptions import ProfilerExecutionError
from great_expectations.experimental.rule_based_profiler.parameter_container import (
ParameterContainer, # noqa: TCH001
)
Expand Down Expand Up @@ -92,7 +92,7 @@ def _get_domains(
)

if not (self.include_column_names and effective_column_names):
raise gx_exceptions.ProfilerExecutionError(
raise ProfilerExecutionError(
message=f'Error: "column_list" in {self.__class__.__name__} must not be empty.'
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import logging
from typing import TYPE_CHECKING, Dict, Optional

import great_expectations.exceptions as gx_exceptions
from great_expectations.experimental.rule_based_profiler.estimators.numeric_range_estimator import (
NumericRangeEstimator,
)
from great_expectations.experimental.rule_based_profiler.exceptions import ProfilerExecutionError
from great_expectations.experimental.rule_based_profiler.helpers.util import (
compute_bootstrap_quantiles_point_estimate,
get_false_positive_rate_from_rule_state,
Expand Down Expand Up @@ -64,7 +64,7 @@ def _get_numeric_range_estimate(
parse_strings_as_datetimes=True,
fuzzy=False,
):
raise gx_exceptions.ProfilerExecutionError(
raise ProfilerExecutionError(
message=f'Estimator "{self.__class__.__name__}" does not support DateTime/TimeStamp data types.' # noqa: E501
)

Expand Down
Loading

0 comments on commit 7f4cd71

Please sign in to comment.