tscode-kg 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tscode_kg/snapshots.py ADDED
@@ -0,0 +1,64 @@
1
+ """
2
+ snapshots.py — Temporal Snapshots of TypeScriptKG Metrics
3
+
4
+ Thin layer over the shared ``kg_utils.snapshots`` module. The shared module
5
+ provides the canonical ``Snapshot``, ``SnapshotManifest``, ``SnapshotManager``,
6
+ and ``PruneResult`` backed by free-form metric dicts; this module re-exports
7
+ those types and adds a ``SnapshotManager`` subclass that defaults
8
+ ``package_name`` to ``"tscode-kg"`` so version auto-detection resolves to this
9
+ package.
10
+
11
+ Snapshots are stored in ``.tscodekg/snapshots/{tree_hash}.json`` with a
12
+ ``manifest.json`` tracking all snapshots and their metrics — the same layout
13
+ PyCodeKG uses under ``.pycodekg/snapshots/``.
14
+
15
+ Usage
16
+ -----
17
+ >>> from tscode_kg.snapshots import SnapshotManager
18
+ >>> mgr = SnapshotManager(".tscodekg/snapshots")
19
+ >>> snapshot = mgr.capture(version="0.1.0", branch="develop", graph_stats_dict=stats)
20
+ >>> mgr.save_snapshot(snapshot)
21
+ >>> manifest = mgr.load_manifest()
22
+
23
+ Author: Eric G. Suchanek, PhD
24
+ """
25
+
26
+ from __future__ import annotations
27
+
28
+ from pathlib import Path
29
+
30
+ from kg_utils.snapshots import (
31
+ PruneResult, # noqa: F401 re-exported
32
+ Snapshot, # noqa: F401 re-exported
33
+ SnapshotManifest, # noqa: F401 re-exported
34
+ )
35
+ from kg_utils.snapshots import SnapshotManager as _BaseSnapshotManager
36
+
37
+ __all__ = [
38
+ "Snapshot",
39
+ "SnapshotManifest",
40
+ "SnapshotManager",
41
+ "PruneResult",
42
+ ]
43
+
44
+
45
+ class SnapshotManager(_BaseSnapshotManager):
46
+ """Snapshot manager bound to the ``tscode-kg`` package.
47
+
48
+ Identical to :class:`kg_utils.snapshots.SnapshotManager` except that
49
+ version auto-detection resolves against the installed ``tscode-kg``
50
+ package instead of ``kg-utils``.
51
+
52
+ :param snapshots_dir: Directory holding snapshot JSON files and manifest.
53
+ :param package_name: Package whose installed version stamps snapshots.
54
+ :param db_path: Optional SQLite graph path for per-module node counts.
55
+ """
56
+
57
+ def __init__(
58
+ self,
59
+ snapshots_dir: Path | str,
60
+ *,
61
+ package_name: str = "tscode-kg",
62
+ db_path: Path | str | None = None,
63
+ ) -> None:
64
+ super().__init__(snapshots_dir, package_name=package_name, db_path=db_path)