config_repository#
- class ConfigRepository(*, base_dir: Path | None = None, known_names: Iterable[str] | None = None, config_groups: List[List[str]] | None = None)[source]#
Bases:
objectFile I/O + atomic commits, powered by ConfigLoader’s resolution: - logical ‘name’ -> path resolution (w/ alternative file names and extensions) - load/commit per file; load_all/commit_all across known names
- static default_path_for(name: str, *, must_exist: bool = True) Path[source]#
Resolve the packaged default for a logical config name.
- clone_from(template_dir: Path, dest_dir: Path) None[source]#
Copy known config files from a template experiment dir.
- commit(name: str, cfg: Dict[str, Any]) None[source]#
Atomically write the given dict to the resolved path. Uses ConfigHandler’s dump() to dispatch to the right format. The write is atomic: first to a temp file, then rename. 2nd step (rename) is atomic on most OS/FS. 1st step (write to temp) is not atomic, but should not leave a partial file behind (unless disk full or similar).
- copy_from_defaults(dest_dir: Path | str) None[source]#
Copy packaged defaults for each known config into dest_dir.
- ensure_present(name: str) Path | None[source]#
Ensure a config file exists in the current experiment directory. If missing, copy from packaged defaults. Return the dest path or None if no default exists for that name.
- exists_any(name: str) bool[source]#
Return True if a config file for ‘name’ exists in the experiment folder, considering all alternative names/extensions and legacy layouts.
- load(name: str) Dict[str, Any][source]#
Return a plain dict for this logical config. (or empty dict if missing).