kgmodule-utils 0.2.0__tar.gz → 0.2.1__tar.gz
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.
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/PKG-INFO +1 -1
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/pyproject.toml +1 -1
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/src/kg_utils/__init__.py +1 -1
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/src/kg_utils/snapshots/manager.py +15 -8
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/LICENSE +0 -0
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/README.md +0 -0
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/src/kg_utils/embed.py +0 -0
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/src/kg_utils/py.typed +0 -0
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/src/kg_utils/snapshots/__init__.py +0 -0
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/src/kg_utils/snapshots/models.py +0 -0
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/src/kg_utils/types/__init__.py +0 -0
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/src/kg_utils/types/extractor.py +0 -0
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/src/kg_utils/types/module.py +0 -0
- {kgmodule_utils-0.2.0 → kgmodule_utils-0.2.1}/src/kg_utils/types/specs.py +0 -0
|
@@ -10,7 +10,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
10
10
|
|
|
11
11
|
[project]
|
|
12
12
|
name = "kgmodule-utils"
|
|
13
|
-
version = "0.2.
|
|
13
|
+
version = "0.2.1"
|
|
14
14
|
description = "Shared types and snapshot infrastructure for the KGModule SDK"
|
|
15
15
|
readme = "README.md"
|
|
16
16
|
license = { text = "Elastic-2.0" }
|
|
@@ -214,10 +214,13 @@ class SnapshotManager:
|
|
|
214
214
|
manifest = SnapshotManifest.from_dict(
|
|
215
215
|
json.loads(self.manifest_path.read_text(encoding="utf-8"))
|
|
216
216
|
)
|
|
217
|
-
# Normalise legacy
|
|
217
|
+
# Normalise legacy key fields -> 'key'
|
|
218
218
|
for entry in manifest.snapshots:
|
|
219
|
-
if "key" not in entry
|
|
220
|
-
|
|
219
|
+
if "key" not in entry:
|
|
220
|
+
if "tree_hash" in entry:
|
|
221
|
+
entry["key"] = entry.pop("tree_hash")
|
|
222
|
+
elif "commit" in entry:
|
|
223
|
+
entry["key"] = entry["commit"]
|
|
221
224
|
return manifest
|
|
222
225
|
|
|
223
226
|
def _save_manifest(self, manifest: SnapshotManifest) -> None:
|
|
@@ -277,19 +280,23 @@ class SnapshotManager:
|
|
|
277
280
|
if not current_ts:
|
|
278
281
|
return None
|
|
279
282
|
prev_entry = None
|
|
280
|
-
for s in sorted(manifest.snapshots, key=lambda x: x
|
|
281
|
-
if s
|
|
283
|
+
for s in sorted(manifest.snapshots, key=lambda x: x.get("timestamp", ""), reverse=True):
|
|
284
|
+
if s.get("timestamp", "") < current_ts:
|
|
282
285
|
prev_entry = s
|
|
283
286
|
break
|
|
284
|
-
|
|
287
|
+
if not prev_entry:
|
|
288
|
+
return None
|
|
289
|
+
prev_key = prev_entry.get("key", "")
|
|
290
|
+
return self.load_snapshot(prev_key) if prev_key else None
|
|
285
291
|
|
|
286
292
|
def get_baseline(self) -> Snapshot | None:
|
|
287
293
|
"""Get the oldest snapshot (baseline for comparison)."""
|
|
288
294
|
manifest = self.load_manifest()
|
|
289
295
|
if not manifest.snapshots:
|
|
290
296
|
return None
|
|
291
|
-
baseline_entry = min(manifest.snapshots, key=lambda x: x
|
|
292
|
-
|
|
297
|
+
baseline_entry = min(manifest.snapshots, key=lambda x: x.get("timestamp", ""))
|
|
298
|
+
baseline_key = baseline_entry.get("key", "")
|
|
299
|
+
return self.load_snapshot(baseline_key) if baseline_key else None
|
|
293
300
|
|
|
294
301
|
def list_snapshots(
|
|
295
302
|
self,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|