예제 #1
0
    def __init__(self, *args, **kwargs):
        include_config = kwargs.pop("include_config", None)
        if include_config is not None and not isinstance(include_config, bool):
            raise InvalidExpectationKwargsError(
                "include_config must be a boolean value")

        result_format = kwargs.get("result_format", None)
        if result_format is None:
            pass
        elif result_format in RESULT_FORMATS:
            pass
        elif (isinstance(result_format, dict)
              and result_format.get("result_format", None) in RESULT_FORMATS):
            pass
        else:
            raise InvalidExpectationKwargsError(
                "result format must be one of the valid formats: %s" %
                str(RESULT_FORMATS))

        catch_exceptions = kwargs.pop("catch_exceptions", None)
        if catch_exceptions is not None and not isinstance(
                catch_exceptions, bool):
            raise InvalidExpectationKwargsError(
                "catch_exceptions must be a boolean value")

        super(ExpectationKwargs, self).__init__(*args, **kwargs)
        ensure_json_serializable(self)
예제 #2
0
 def get_domain_kwargs(self):
     expectation_kwargs_dict = self.kwarg_lookup_dict.get(
         self.expectation_type, None
     )
     if expectation_kwargs_dict is None:
         impl = get_expectation_impl(self.expectation_type)
         if impl is not None:
             domain_keys = impl.domain_keys
             default_kwarg_values = impl.default_kwarg_values
         else:
             expectation_kwargs_dict = self._get_default_custom_kwargs()
             default_kwarg_values = expectation_kwargs_dict.get(
                 "default_kwarg_values", dict()
             )
             domain_keys = expectation_kwargs_dict["domain_kwargs"]
     else:
         default_kwarg_values = expectation_kwargs_dict.get(
             "default_kwarg_values", dict()
         )
         domain_keys = expectation_kwargs_dict["domain_kwargs"]
     domain_kwargs = {
         key: self.kwargs.get(key, default_kwarg_values.get(key))
         for key in domain_keys
     }
     missing_kwargs = set(domain_keys) - set(domain_kwargs.keys())
     if missing_kwargs:
         raise InvalidExpectationKwargsError(
             f"Missing domain kwargs: {list(missing_kwargs)}"
         )
     return domain_kwargs
예제 #3
0
    def get_domain_kwargs(
        self, configuration: Optional[ExpectationConfiguration] = None
    ):
        if not configuration:
            configuration = self.configuration

        domain_kwargs = {
            key: configuration.kwargs.get(key, self.default_kwarg_values.get(key))
            for key in self.domain_keys
        }
        # Process evaluation parameter dependencies

        missing_kwargs = set(self.domain_keys) - set(domain_kwargs.keys())
        if missing_kwargs:
            raise InvalidExpectationKwargsError(
                f"Missing domain kwargs: {list(missing_kwargs)}"
            )
        return domain_kwargs