module documentation
This module provides context for Kedro project.
Function | _convert |
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 |
Checks whether a path string is a relative path. |
Function | _update |
Update a nested dict with values of new_dict. |
Function | _validate |
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 | |
projectPath | The root directory to prepend to relative path to make absolute path. |
confDict[ | The configuration containing paths to expand. |
Returns | |
Dict[ | A dictionary containing only absolute paths. |
Raises | |
ValueError | If the provided project_path is not an absolute path. |
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 | |
pathstr | The path string to check. |
Returns | |
bool | Whether the string is a relative path. |