great_expectations.data_context.util

Module Contents

Classes

PasswordMasker()

Used to mask passwords in Datasources. Does not mask sqlite urls.

Functions

instantiate_class_from_config(config, runtime_environment, config_defaults=None)

Build a GX class from configuration dictionaries.

build_store_from_config(store_name: Optional[str] = None, store_config: Optional[dict] = None, module_name: str = ‘great_expectations.data_context.store’, runtime_environment: Optional[dict] = None)

format_dict_for_error_message(dict_)

file_relative_path(dunderfile, relative_path)

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

parse_substitution_variable(substitution_variable: str)

Parse and check whether the string contains a substitution variable of the case insensitive form ${SOME_VAR} or $SOME_VAR

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

Build a GX class from configuration dictionaries.

great_expectations.data_context.util.build_store_from_config(store_name: Optional[str] = None, store_config: Optional[dict] = None, module_name: str = 'great_expectations.data_context.store', runtime_environment: Optional[dict] = None) → Optional['Store']
great_expectations.data_context.util.format_dict_for_error_message(dict_)
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

great_expectations.data_context.util.parse_substitution_variable(substitution_variable: str) → Optional[str]

Parse and check whether the string contains a substitution variable of the case insensitive form ${SOME_VAR} or $SOME_VAR :param substitution_variable: string to be parsed

Returns

string of variable name e.g. SOME_VAR or None if not parsable. If there are multiple substitution variables this currently returns the first e.g. $SOME_$TRING -> $SOME_

class great_expectations.data_context.util.PasswordMasker

Used to mask passwords in Datasources. Does not mask sqlite urls.

Example usage masked_db_url = PasswordMasker.mask_db_url(url) where url = “postgresql+psycopg2://username:password@host:65432/database” and masked_url = “postgresql+psycopg2://username:***@host:65432/database”

MASKED_PASSWORD_STRING = ***
URL_KEYS
PASSWORD_KEYS
classmethod mask_db_url(cls, url: str, use_urlparse: bool = False, **kwargs)

Mask password in database url. Uses sqlalchemy engine parsing if sqlalchemy is installed, otherwise defaults to using urlparse from the stdlib which does not handle kwargs. :param url: Database url e.g. “postgresql+psycopg2://username:password@host:65432/database” :param use_urlparse: Skip trying to parse url with sqlalchemy and use urlparse :param **kwargs: passed to create_engine()

Returns

//username:***@host:65432/database”

Return type

url with password masked e.g. “postgresql+psycopg2

classmethod _mask_db_url_no_sa(cls, url: str)
classmethod sanitize_config(cls, config: dict)

Mask sensitive fields in a Dict.