Exemplo n.º 1
0
    def validate_schema(self, data, **kwargs):
        if "config_version" not in data:
            raise ge_exceptions.InvalidDataContextConfigError(
                "The key `config_version` is missing; please check your config file.",
                validation_error=ValidationError("no config_version key"),
            )

        if not isinstance(data["config_version"], (int, float)):
            raise ge_exceptions.InvalidDataContextConfigError(
                "The key `config_version` must be a number. Please check your config file.",
                validation_error=ValidationError(
                    "config version not a number"),
            )

        # When migrating from 0.7.x to 0.8.0
        if data["config_version"] == 0 and ("validations_store" in list(
                data.keys()) or "validations_stores" in list(data.keys())):
            raise ge_exceptions.UnsupportedConfigVersionError(
                "You appear to be using a config version from the 0.7.x series. This version is no longer supported."
            )
        elif data["config_version"] < MINIMUM_SUPPORTED_CONFIG_VERSION:
            raise ge_exceptions.UnsupportedConfigVersionError(
                "You appear to have an invalid config version ({}).\n    The version number must be between {} and {}."
                .format(
                    data["config_version"],
                    MINIMUM_SUPPORTED_CONFIG_VERSION,
                    CURRENT_CONFIG_VERSION,
                ), )
        elif data["config_version"] > CURRENT_CONFIG_VERSION:
            raise ge_exceptions.InvalidDataContextConfigError(
                "You appear to have an invalid config version ({}).\n    The maximum valid version is {}."
                .format(data["config_version"], CURRENT_CONFIG_VERSION),
                validation_error=ValidationError("config version too high"),
            )
Exemplo n.º 2
0
def cli(
    ctx: click.Context,
    v3_api: bool,
    verbose: bool,
    config_file_location: Optional[str],
    assume_yes: bool,
) -> None:
    """
    Welcome to the great_expectations CLI!

    Most commands follow this format: great_expectations <NOUN> <VERB>

    The nouns are: checkpoint, datasource, docs, init, project, store, suite, validation-operator.
    Most nouns accept the following verbs: new, list, edit
    """
    logger = _set_up_logger()
    if verbose:
        # Note we are explicitly not using a logger in all CLI output to have
        # more control over console UI.
        logger.setLevel(logging.DEBUG)
    ctx.obj = CLIState(v3_api=v3_api,
                       config_file_location=config_file_location,
                       assume_yes=assume_yes)

    if v3_api:
        cli_message("Using v3 (Batch Request) API")
    else:
        cli_message("Using v2 (Batch Kwargs) API")

        ge_config_version: float = (ctx.obj.get_data_context_from_config_file(
        ).get_config().config_version)
        if ge_config_version >= FIRST_GE_CONFIG_VERSION_WITH_CHECKPOINT_STORE:
            raise ge_exceptions.InvalidDataContextConfigError(
                f"Using the legacy v2 (Batch Kwargs) API with a recent config version ({ge_config_version}) is illegal."
            )
Exemplo n.º 3
0
 def handle_error(self, exc, data, **kwargs):
     """Log and raise our custom exception when (de)serialization fails."""
     logger.error(exc.messages)
     raise ge_exceptions.InvalidDataContextConfigError(
         "Error while processing DataContextConfig.", exc)