示例#1
0
class ValidationsStore(Store):
    _key_class = ValidationResultIdentifier

    def __init__(self, store_backend=None, runtime_environment=None):
        self._expectationSuiteValidationResultSchema = ExpectationSuiteValidationResultSchema(
            strict=True)

        if store_backend is not None:
            store_backend_module_name = store_backend.get(
                "module_name", "great_expectations.data_context.store")
            store_backend_class_name = store_backend.get(
                "class_name", "InMemoryStoreBackend")
            store_backend_class = load_class(store_backend_class_name,
                                             store_backend_module_name)

            if issubclass(store_backend_class, TupleStoreBackend):
                # Provide defaults for this common case
                store_backend["filepath_suffix"] = store_backend.get(
                    "filepath_suffix", ".json")
            elif issubclass(store_backend_class, DatabaseStoreBackend):
                # Provide defaults for this common case
                store_backend["table_name"] = store_backend.get(
                    "table_name", "ge_validations_store")
                store_backend["key_columns"] = store_backend.get(
                    "key_columns",
                    ["expectation_suite_name", "run_id", "batch_identifier"])
        super(ValidationsStore,
              self).__init__(store_backend=store_backend,
                             runtime_environment=runtime_environment)

    def serialize(self, key, value):
        return self._expectationSuiteValidationResultSchema.dumps(value).data

    def deserialize(self, key, value):
        return self._expectationSuiteValidationResultSchema.loads(value).data
示例#2
0
    def __init__(self, store_backend=None, runtime_environment=None):
        self._expectationSuiteValidationResultSchema = ExpectationSuiteValidationResultSchema(
        )

        if store_backend is not None:
            store_backend_module_name = store_backend.get(
                "module_name", "great_expectations.data_context.store")
            store_backend_class_name = store_backend.get(
                "class_name", "InMemoryStoreBackend")
            verify_dynamic_loading_support(
                module_name=store_backend_module_name, package_name=None)
            store_backend_class = load_class(store_backend_class_name,
                                             store_backend_module_name)

            # Store Backend Class was loaded successfully; verify that it is of a correct subclass.
            if issubclass(store_backend_class, TupleStoreBackend):
                # Provide defaults for this common case
                store_backend["filepath_suffix"] = store_backend.get(
                    "filepath_suffix", ".json")
            elif issubclass(store_backend_class, DatabaseStoreBackend):
                # Provide defaults for this common case
                store_backend["table_name"] = store_backend.get(
                    "table_name", "ge_validations_store")
                store_backend["key_columns"] = store_backend.get(
                    "key_columns",
                    ["expectation_suite_name", "run_id", "batch_identifier"])
        super().__init__(store_backend=store_backend,
                         runtime_environment=runtime_environment)
def validation_operator_result():
    fixture_filename = os.path.join(
        os.path.dirname(__file__),
        "fixtures/ValidationOperatorResult_with_multiple_validation_results.json",
    )
    with open(fixture_filename) as infile:
        validation_operator_result = json.load(infile,
                                               object_pairs_hook=OrderedDict)
        run_results = validation_operator_result["run_results"]
        for k, validation_result in run_results.items():
            validation_result[
                "validation_result"] = ExpectationSuiteValidationResultSchema(
                ).load(validation_result["validation_result"])
        return validation_operator_result
示例#4
0
from dateutil.parser import parse

from great_expectations.core import (
    ExpectationSuiteValidationResultSchema,
    ExpectationValidationResultSchema,
)
from great_expectations.dataset import (
    PandasDataset,
    SparkDFDataset,
    SqlAlchemyDataset,
)
from great_expectations.profile import ColumnsExistProfiler

expectationValidationResultSchema = ExpectationValidationResultSchema(
    strict=True)
expectationSuiteValidationResultSchema = ExpectationSuiteValidationResultSchema(
    strict=True)

try:
    import sqlalchemy.dialects.sqlite as sqlitetypes
    SQLITE_TYPES = {
        "VARCHAR": sqlitetypes.VARCHAR,
        "CHAR": sqlitetypes.CHAR,
        "INTEGER": sqlitetypes.INTEGER,
        "SMALLINT": sqlitetypes.SMALLINT,
        "DATETIME": sqlitetypes.DATETIME(truncate_microseconds=True),
        "DATE": sqlitetypes.DATE,
        "FLOAT": sqlitetypes.FLOAT,
        "BOOLEAN": sqlitetypes.BOOLEAN,
        "TIMESTAMP": sqlitetypes.TIMESTAMP
    }
except ImportError:
示例#5
0
import numpy as np
import pandas as pd
import pytest
from dateutil.parser import parse

from great_expectations.core import (
    ExpectationSuiteValidationResultSchema,
    ExpectationValidationResultSchema,
)
from great_expectations.dataset import PandasDataset, SparkDFDataset, SqlAlchemyDataset
from great_expectations.dataset.util import (
    get_sql_dialect_floating_point_infinity_value, )
from great_expectations.profile import ColumnsExistProfiler

expectationValidationResultSchema = ExpectationValidationResultSchema()
expectationSuiteValidationResultSchema = ExpectationSuiteValidationResultSchema(
)

try:
    from sqlalchemy import create_engine
except ImportError:
    create_engine = None

try:
    import sqlalchemy.dialects.sqlite as sqlitetypes

    SQLITE_TYPES = {
        "VARCHAR": sqlitetypes.VARCHAR,
        "CHAR": sqlitetypes.CHAR,
        "INTEGER": sqlitetypes.INTEGER,
        "SMALLINT": sqlitetypes.SMALLINT,
        "DATETIME": sqlitetypes.DATETIME(truncate_microseconds=True),