module documentation

This module provides context for Kedro project.

Function _convert_paths_to_absolute_posix Turn all relative paths inside conf_dictionary into absolute paths by appending them to project_path and convert absolute Windows paths to POSIX format. This is a hack to make sure that we don't have to change user's working directory for logging and datasets to work...
Function _is_relative_path Checks whether a path string is a relative path.
Function _update_nested_dict Update a nested dict with values of new_dict.
Function _validate_layers_for_transcoding Check that transcoded names that correspond to the same dataset also belong to the same layer.
def _convert_paths_to_absolute_posix(project_path: Path, conf_dictionary: Dict[str, Any]) -> Dict[str, Any]: (source)

Turn all relative paths inside conf_dictionary into absolute paths by appending them to project_path and convert absolute Windows paths to POSIX format. This is a hack to make sure that we don't have to change user's working directory for logging and datasets to work. It is important for non-standard workflows such as IPython notebook where users don't go through kedro run or __main__.py entrypoints.

Example:

>>> conf = _convert_paths_to_absolute_posix(
>>>     project_path=Path("/path/to/my/project"),
>>>     conf_dictionary={
>>>         "handlers": {
>>>             "info_file_handler": {
>>>                 "filename": "logs/info.log"
>>>             }
>>>         }
>>>     }
>>> )
>>> print(conf['handlers']['info_file_handler']['filename'])
"/path/to/my/project/logs/info.log"
Parameters
project_path:PathThe root directory to prepend to relative path to make absolute path.
conf_dictionary:Dict[str, Any]The configuration containing paths to expand.
Returns
Dict[str, Any]A dictionary containing only absolute paths.
Raises
ValueErrorIf the provided project_path is not an absolute path.
def _is_relative_path(path_string: str) -> bool: (source)

Checks whether a path string is a relative path.

Example:

>>> _is_relative_path("data/01_raw") == True
>>> _is_relative_path("logs/info.log") == True
>>> _is_relative_path("/tmp/data/01_raw") == False
>>> _is_relative_path(r"C:\logs\info.log") == False
>>> _is_relative_path(r"\logs\'info.log") == False
>>> _is_relative_path("c:/logs/info.log") == False
>>> _is_relative_path("s3://logs/info.log") == False
Parameters
path_string:strThe path string to check.
Returns
boolWhether the string is a relative path.
def _update_nested_dict(old_dict: Dict[Any, Any], new_dict: Dict[Any, Any]): (source)

Update a nested dict with values of new_dict.

Parameters
old_dict:Dict[Any, Any]dict to be updated
new_dict:Dict[Any, Any]dict to use for updating old_dict
def _validate_layers_for_transcoding(catalog: DataCatalog): (source)

Check that transcoded names that correspond to the same dataset also belong to the same layer.