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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kgmodule-utils
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Shared types and snapshot infrastructure for the KGModule SDK
5
5
  License: Elastic-2.0
6
6
  License-File: LICENSE
@@ -10,7 +10,7 @@ build-backend = "poetry.core.masonry.api"
10
10
 
11
11
  [project]
12
12
  name = "kgmodule-utils"
13
- version = "0.2.0"
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" }
@@ -7,4 +7,4 @@ Sub-packages:
7
7
  kg_model_cache_dir(), resolve_model_path().
8
8
  """
9
9
 
10
- __version__ = "0.1.0"
10
+ __version__ = "0.2.1"
@@ -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 'tree_hash' -> 'key'
217
+ # Normalise legacy key fields -> 'key'
218
218
  for entry in manifest.snapshots:
219
- if "key" not in entry and "tree_hash" in entry:
220
- entry["key"] = entry.pop("tree_hash")
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["timestamp"], reverse=True):
281
- if s["timestamp"] < current_ts:
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
- return self.load_snapshot(prev_entry["key"]) if prev_entry else None
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["timestamp"])
292
- return self.load_snapshot(baseline_entry["key"])
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