def test_build_data_docs_skipping_index_does_not_build_index( tmp_path_factory, ): # TODO What's the latest and greatest way to use configs rather than my hackery? empty_directory = str(tmp_path_factory.mktemp("empty")) DataContext.create(empty_directory) ge_dir = os.path.join(empty_directory, DataContext.GE_DIR) context = DataContext(ge_dir) config = context.get_config() config.data_docs_sites = { "local_site": { "class_name": "SiteBuilder", "store_backend": { "class_name": "TupleFilesystemStoreBackend", "base_directory": os.path.join("uncommitted", "data_docs"), }, }, } context._project_config = config # TODO Workaround project config programmatic config manipulation # statefulness issues by writing to disk and re-upping a new context context._save_project_config() del context context = DataContext(ge_dir) data_docs_dir = os.path.join(ge_dir, "uncommitted", "data_docs") index_path = os.path.join(data_docs_dir, "index.html") assert not os.path.isfile(index_path) context.build_data_docs(build_index=False) assert os.path.isdir(os.path.join(data_docs_dir, "static")) assert not os.path.isfile(index_path)
def do_config_check(target_directory): is_config_ok: bool = True upgrade_message: str = "" context: Optional[DataContext] try: context = DataContext(context_root_dir=target_directory) ge_config_version: int = context.get_config().config_version if int(ge_config_version) < CURRENT_GE_CONFIG_VERSION: is_config_ok = False upgrade_message = f"""The config_version of your great_expectations.yml -- {float(ge_config_version)} -- is outdated. Please consult the V3 API migration guide https://docs.greatexpectations.io/docs/guides/miscellaneous/migration_guide#migrating-to-the-batch-request-v3-api and upgrade your Great Expectations configuration to version {float(CURRENT_GE_CONFIG_VERSION)} in order to take advantage of the latest capabilities. """ context = None elif int(ge_config_version) > CURRENT_GE_CONFIG_VERSION: raise ge_exceptions.UnsupportedConfigVersionError( f"""Invalid config version ({ge_config_version}).\n The maximum valid version is \ {CURRENT_GE_CONFIG_VERSION}. """) else: upgrade_helper_class = GE_UPGRADE_HELPER_VERSION_MAP.get( int(ge_config_version)) if upgrade_helper_class: upgrade_helper = upgrade_helper_class(data_context=context, update_version=False) manual_steps_required = upgrade_helper.manual_steps_required() if manual_steps_required: ( upgrade_overview, confirmation_required, ) = upgrade_helper.get_upgrade_overview() upgrade_overview = cli_colorize_string(upgrade_overview) cli_message(string=upgrade_overview) is_config_ok = False upgrade_message = """The configuration of your great_expectations.yml is outdated. Please \ consult the V3 API migration guide \ https://docs.greatexpectations.io/docs/guides/miscellaneous/migration_guide#migrating-to-the-batch-request-v3-api and upgrade your \ Great Expectations configuration in order to take advantage of the latest capabilities. """ context = None except ( ge_exceptions.InvalidConfigurationYamlError, ge_exceptions.InvalidTopLevelConfigKeyError, ge_exceptions.MissingTopLevelConfigKeyError, ge_exceptions.InvalidConfigValueTypeError, ge_exceptions.UnsupportedConfigVersionError, ge_exceptions.DataContextError, ge_exceptions.PluginClassNotFoundError, ge_exceptions.PluginModuleNotFoundError, ge_exceptions.GreatExpectationsError, ) as err: is_config_ok = False upgrade_message = err.message context = None return ( is_config_ok, upgrade_message, context, )