def get_validator_with_expectation_suite( batch_request: Union[BatchRequestBase, dict], data_context: "BaseDataContext", # noqa: F821 expectation_suite: Optional["ExpectationSuite"] = None, # noqa: F821 expectation_suite_name: Optional[str] = None, component_name: str = "test", persist: bool = False, ) -> "Validator": # noqa: F821 """ Instantiates and returns "Validator" object using "data_context", "batch_request", and other available information. Use "expectation_suite" if provided. If not, then if "expectation_suite_name" is specified, then create "ExpectationSuite" from it. Otherwise, generate temporary "expectation_suite_name" using supplied "component_name". """ assert expectation_suite is None or isinstance(expectation_suite, ExpectationSuite) assert expectation_suite_name is None or isinstance( expectation_suite_name, str) expectation_suite = get_or_create_expectation_suite( data_context=data_context, expectation_suite=expectation_suite, expectation_suite_name=expectation_suite_name, component_name=component_name, persist=persist, ) batch_request = materialize_batch_request(batch_request=batch_request) validator: "Validator" = data_context.get_validator( # noqa: F821 batch_request=batch_request, expectation_suite=expectation_suite, ) return validator
def get_substituted_batch_request( substituted_runtime_config: dict, validation_batch_request: Optional[Union[BatchRequestBase, dict]] = None, ) -> Optional[Union[BatchRequest, RuntimeBatchRequest]]: substituted_runtime_batch_request = substituted_runtime_config.get("batch_request") if substituted_runtime_batch_request is None and validation_batch_request is None: return None if substituted_runtime_batch_request is None: substituted_runtime_batch_request = {} if validation_batch_request is None: validation_batch_request = {} validation_batch_request = get_batch_request_as_dict( batch_request=validation_batch_request ) substituted_runtime_batch_request = get_batch_request_as_dict( batch_request=substituted_runtime_batch_request ) for key, value in validation_batch_request.items(): substituted_value = substituted_runtime_batch_request.get(key) if value is not None and substituted_value is not None: raise ge_exceptions.CheckpointError( f'BatchRequest attribute "{key}" was specified in both validation and top-level CheckpointConfig.' ) effective_batch_request: dict = dict( **substituted_runtime_batch_request, **validation_batch_request ) return materialize_batch_request(batch_request=effective_batch_request)
def build_batch_request( batch_request: Optional[Union[str, BatchRequestBase, dict]] = None, domain: Optional[Domain] = None, variables: Optional[ParameterContainer] = None, parameters: Optional[Dict[str, ParameterContainer]] = None, ) -> Optional[Union[BatchRequest, RuntimeBatchRequest]]: if batch_request is None: return None # Obtain BatchRequest from "rule state" (i.e., variables and parameters); from instance variable otherwise. effective_batch_request: Optional[ Union[BatchRequestBase, dict]] = get_parameter_value_and_validate_return_type( domain=domain, parameter_reference=batch_request, expected_return_type=(BatchRequestBase, dict), variables=variables, parameters=parameters, ) materialized_batch_request: Optional[Union[ BatchRequest, RuntimeBatchRequest]] = materialize_batch_request( batch_request=effective_batch_request) return materialized_batch_request