great_expectations.data_context.util

Module Contents

Functions

load_class(class_name, module_name)

Dynamically load a class from strings or raise a helpful error.

instantiate_class_from_config(config, runtime_environment, config_defaults=None)

Build a GE class from configuration dictionaries.

format_dict_for_error_message(dict_)

substitute_config_variable(template_str, config_variables_dict)

This method takes a string, and if it contains a pattern ${SOME_VARIABLE} or $SOME_VARIABLE,

substitute_all_config_variables(data, replace_variables_dict)

Substitute all config variables of the form ${SOME_VARIABLE} in a dictionary-like

file_relative_path(dunderfile, relative_path)

This function is useful when one needs to load a file that is

great_expectations.data_context.util.logger
great_expectations.data_context.util.load_class(class_name, module_name)

Dynamically load a class from strings or raise a helpful error.

great_expectations.data_context.util.instantiate_class_from_config(config, runtime_environment, config_defaults=None)

Build a GE class from configuration dictionaries.

great_expectations.data_context.util.format_dict_for_error_message(dict_)
great_expectations.data_context.util.substitute_config_variable(template_str, config_variables_dict)

This method takes a string, and if it contains a pattern ${SOME_VARIABLE} or $SOME_VARIABLE, returns a string where the pattern is replaced with the value of SOME_VARIABLE, otherwise returns the string unchanged.

If the environment variable SOME_VARIABLE is set, the method uses its value for substitution. If it is not set, the value of SOME_VARIABLE is looked up in the config variables store (file). If it is not found there, the input string is returned as is.

Parameters
  • template_str – a string that might or might not be of the form ${SOME_VARIABLE} or $SOME_VARIABLE

  • config_variables_dict – a dictionary of config variables. It is loaded from the config variables store (by default, “uncommitted/config_variables.yml file)

Returns

great_expectations.data_context.util.substitute_all_config_variables(data, replace_variables_dict)

Substitute all config variables of the form ${SOME_VARIABLE} in a dictionary-like config object for their values.

The method traverses the dictionary recursively.

Parameters
  • data

  • replace_variables_dict

Returns

a dictionary with all the variables replaced with their values

great_expectations.data_context.util.file_relative_path(dunderfile, relative_path)

This function is useful when one needs to load a file that is relative to the position of the current file. (Such as when you encode a configuration file path in source file and want in runnable in any current working directory)

It is meant to be used like the following: file_relative_path(__file__, ‘path/relative/to/file’)

H/T https://github.com/dagster-io/dagster/blob/8a250e9619a49e8bff8e9aa7435df89c2d2ea039/python_modules/dagster/dagster/utils/__init__.py#L34