Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] V1 Validation scaffolding #9508

Merged
merged 10 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions great_expectations/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@
from .id_dict import IDDict
from .run_identifier import RunIdentifier, RunIdentifierSchema
from .urn import ge_urn
from .validation import Validation

__all__ = [
"Domain",
"ExpectationSuite",
"ExpectationSuiteSchema",
"expectationSuiteSchema",
"ExpectationSuiteValidationResult",
"ExpectationSuiteValidationResultSchema",
"ExpectationValidationResult",
"ExpectationValidationResultSchema",
"expectationSuiteValidationResultSchema",
"expectationValidationResultSchema",
"get_metric_kwargs_id",
"IDDict",
"RunIdentifier",
"RunIdentifierSchema",
"Validation",
"expectationSuiteSchema",
"expectationSuiteValidationResultSchema",
"expectationValidationResultSchema",
"ge_urn",
"get_metric_kwargs_id",
]

logger = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions great_expectations/core/factory/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .checkpoint_factory import CheckpointFactory
from .suite_factory import SuiteFactory
from .validation_factory import ValidationFactory
56 changes: 56 additions & 0 deletions great_expectations/core/factory/validation_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from great_expectations._docs_decorators import public_api
from great_expectations.compatibility.typing_extensions import override
from great_expectations.core.factory.factory import Factory

if TYPE_CHECKING:
from great_expectations.core.validation import Validation
from great_expectations.data_context.store.validations_store import ValidationsStore


# TODO: Add analytics as needed
class ValidationFactory(Factory[Validation]):
def __init__(self, store: ValidationsStore) -> None:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current store won't work so we'll need to update accordingly

self._store = store

@public_api
@override
def add(self, validation: Validation) -> Validation:
"""Add a Validation to the collection.

Parameters:
validation: Validation to add

Raises:
DataContextError if Validation already exists
"""
raise NotImplementedError

@public_api
@override
def delete(self, validation: Validation) -> Validation:
"""Delete a Validation from the collection.

Parameters:
validation: Validation to delete

Raises:
DataContextError if Validation doesn't exist
"""
raise NotImplementedError

@public_api
@override
def get(self, name: str) -> Validation:
"""Get a Validation from the collection by name.

Parameters:
name: Name of Validation to get

Raises:
DataContextError when Validation is not found.
"""
raise NotImplementedError
39 changes: 39 additions & 0 deletions great_expectations/core/validation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from great_expectations.core.batch_config import BatchConfig
from great_expectations.core.expectation_suite import ExpectationSuite
from great_expectations.datasource.fluent.interfaces import DataAsset


class Validation:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this to be a Pydantic model? Went back and forth on it but figured its a pretty lightweight object so we can just add it if we need (probably when persistence comes into question?)

"""
TBD
"""

def __init__(
self,
name: str,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not part of the spec but we need an identifier if we want persistence

data: DataAsset | BatchConfig,
expectation_suite: ExpectationSuite,
) -> None:
self._name = name
self._data = data
self._suite = expectation_suite

@property
def name(self) -> str:
return self._name

@property
def data(self) -> BatchConfig:
return self._data

@property
def suite(self) -> ExpectationSuite:
return self._suite

def run(self):
raise NotImplementedError
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@
_RuntimeEnvironmentConfigurationProvider,
)
from great_expectations.core.expectation_validation_result import get_metric_kwargs_id
from great_expectations.core.factory import CheckpointFactory, SuiteFactory
from great_expectations.core.factory import (
CheckpointFactory,
SuiteFactory,
ValidationFactory,
)
from great_expectations.core.id_dict import BatchKwargs
from great_expectations.core.serializer import (
AbstractConfigSerializer,
Expand Down Expand Up @@ -329,6 +333,10 @@ def _init_factories(self) -> None:
context=self,
)

self._validations: ValidationFactory | None = None
if validation_store := self.stores.get(self.validations_store_name):
self._validations = ValidationFactory(store=validation_store)

def _init_analytics(self) -> None:
init_analytics(
data_context_id=uuid.UUID(self._data_context_id),
Expand Down