boltzkit.utils.cached_repo
Module Attributes
Write text bytes: write binary Callable: creates file at path |
Functions
|
Creates CachedRepo object from the given URI (Unified Resource Identifier). |
|
|
|
Returns the relative path to the given repo root. |
Classes
Abstract base class representing a cached repository. |
|
Creates cache directory from in-memory content, i.e., cache dir is not backed by some form of directory or repository |
- boltzkit.utils.cached_repo.strip_repo_prefix(full_path: str, repo_root: str) str[source]
Returns the relative path to the given repo root.
- class boltzkit.utils.cached_repo.CachedRepo[source]
Bases:
ABCAbstract base class representing a cached repository.
A CachedRepo provides a unified interface for interacting with remote repositories (e.g., Huggingface datasets or local directories) while caching files locally for efficient repeated access.
- remote_uri
The URI or path of the remote repository.
- Type:
str
- local_path
The local directory where files are cached.
- Type:
Path
- __init__(remote_uri: str, local_repo_path: Path, lazy_load: bool)[source]
Initialize a CachedRepo instance.
- Parameters:
remote_uri (str) – The remote repository URI or path.
local_repo_path (Path) – Local path where cached files will be stored.
lazy_load (bool) – If True, files are loaded on demand; if False, all files are loaded immediately.
- find_file(regex: str) list[str][source]
Return all remote files matching the given regex pattern.
- Parameters:
regex (str) – Regular expression to match against file paths.
- Returns:
List of matching file paths (repo-relative).
- Return type:
List[str]
- property config: dict[str, Any]
- property remote_uri: str
- property local_path: Path
- class boltzkit.utils.cached_repo.HuggingfaceRepo[source]
Bases:
CachedRepo- __init__(remote_uri, local_repo_path, lazy_load)[source]
Initialize a CachedRepo instance.
- Parameters:
remote_uri (str) – The remote repository URI or path.
local_repo_path (Path) – Local path where cached files will be stored.
lazy_load (bool) – If True, files are loaded on demand; if False, all files are loaded immediately.
- class boltzkit.utils.cached_repo.LocalRepo[source]
Bases:
CachedRepo- __init__(remote_uri, local_repo_path, lazy_load)[source]
Initialize a CachedRepo instance.
- Parameters:
remote_uri (str) – The remote repository URI or path.
local_repo_path (Path) – Local path where cached files will be stored.
lazy_load (bool) – If True, files are loaded on demand; if False, all files are loaded immediately.
- boltzkit.utils.cached_repo.Content
Write text bytes: write binary Callable: creates file at path
- Type:
str
alias of
str|bytes|Callable[[Path],None]
- class boltzkit.utils.cached_repo.VirtualRepo[source]
Bases:
CachedRepoCreates cache directory from in-memory content, i.e., cache dir is not backed by some form of directory or repository