imitation.util.sacred#
Helper methods for the sacred experimental configuration and logging framework.
Functions
|
Constructs a symlink "{log_dir}/sacred" => "${SACRED_PATH}". |
|
|
|
|
|
Walks through a directory tree, returning paths to filtered subdirectories. |
Returns path to the sacred directory, or None if not found. |
Classes
|
Each dict foo is loaded from f"{sacred_dir}/foo.json". |
- class imitation.util.sacred.SacredDicts(sacred_dir: Path, config: dict, run: dict)[source]#
Bases:
tuple
Each dict foo is loaded from f”{sacred_dir}/foo.json”.
- config: dict#
- run: dict#
- sacred_dir: Path#
- imitation.util.sacred.build_sacred_symlink(log_dir, run)[source]#
Constructs a symlink “{log_dir}/sacred” => “${SACRED_PATH}”.
- Return type
None
- imitation.util.sacred.dict_get_nested(d, nested_key, *, sep='.', default=None)[source]#
- Return type
Any
- imitation.util.sacred.filter_subdirs(root_dir, filter_fn=<function dir_contains_sacred_jsons>, *, nested_ok=False)[source]#
Walks through a directory tree, returning paths to filtered subdirectories.
Does not follow symlinks.
- Parameters
root_dir (
Path
) – The start of the directory tree walk.filter_fn (
Callable
[[Path
],bool
]) – A function with takes a directory path and returns True if we should include the directory path in this function’s return value.nested_ok (
bool
) – Allow returning “nested” directories, i.e. a return value where some elements are subdirectories of other elements.
- Return type
Sequence
[Path
]- Returns
A list of all subdirectory paths where filter_fn(path) == True.
- Raises
ValueError – If nested_ok is False and one of the filtered directory paths is a subdirecotry of another.