Data Manager#
- class DataManager(disable_cache: bool = False)[source]#
Caches patch data on disk and (de)serializes it between DataFrames and
PatchTitleobjects.The
DataManagerclass owns persistence for patch reports: caching snapshots on disk and converting between DataFrames andPatchTitleobjects. Report rendering lives inExporter.Data caching can be disabled by setting
disable_cachetoTrueat runtime.- Parameters:
disable_cache (bool) – Whether caching functionality should be disabled.
- property titles: list[PatchTitle][source]#
Retrieve and validate the current list of
PatchTitleobjects.If titles are not already loaded, they are fetched from the latest available dataset.
- Returns:
The validated list of
PatchTitleobjects.- Return type:
list[
PatchTitle]- Raises:
PatcherError – If validation fails.
- build_and_cache(patch_titles: list[PatchTitle]) DataFrame[source]#
Build the canonical DataFrame from
patch_titlesand cache it to disk.The full-fidelity frame (every column) is what gets cached; callers that render reports drop presentation-excluded columns downstream. Caching is a no-op when the cache is disabled.
- Parameters:
patch_titles (list[
PatchTitle]) – Titles to serialize and snapshot.- Returns:
The canonical DataFrame built from the titles.
- Return type:
- static snapshot_label(path: Path) str[source]#
Human-readable label for a cached snapshot file (mtime-derived).
- static closest_snapshot(snapshots: list[Path], target: date) Path[source]#
Pick the snapshot whose mtime is closest to
target.
- sorted_cached_files() list[Path][source]#
Return cached snapshot files sorted oldest → newest by mtime.
- static select_baseline(cached: list[Path], *, since: timedelta | None = None, all_time: bool = False, default: Path) Path[source]#
Pick the baseline (
from) snapshot from a sorted cache list.all_timeselects the earliest snapshot ever cached;sinceselects the earliest within the trailing window; otherwisedefaultis used.
- reset_cache() bool[source]#
Removes all cached files from Cache directory. See reset.
- Returns:
True if all files were able to be removed, False otherwise.
- Return type:
- get_latest_dataset() Path | None[source]#
Retrieves the most recent dataset of patch reports and returns the path.
If a tracked Excel file is available, it is preferred. Otherwise, searches the cache directory.
- Returns:
Path to the latest dataset (Excel or pickle file), or None if no dataset is found.
- Return type:
Path | None