MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / prune_checkpoints

Function prune_checkpoints

core/checkpoint.py:277–305  ·  view source on GitHub ↗

Remove old checkpoints, keeping only the most recent ones. Args: keep_count: Number of recent checkpoints to keep

(keep_count: int = 5)

Source from the content-addressed store, hash-verified

275
276
277def prune_checkpoints(keep_count: int = 5):
278 """
279 Remove old checkpoints, keeping only the most recent ones.
280
281 Args:
282 keep_count: Number of recent checkpoints to keep
283 """
284 state = get_state_store()
285 checkpoints = state.get_checkpoints(100) # Get all
286
287 if len(checkpoints) <= keep_count:
288 return
289
290 to_remove = checkpoints[keep_count:]
291
292 for cp in to_remove:
293 checkpoint_id = cp["id"]
294 backup_dir = CHECKPOINT_DIR / checkpoint_id
295
296 # Remove backup directory
297 if backup_dir.exists():
298 shutil.rmtree(backup_dir)
299
300 # Remove from database
301 state.delete_checkpoint(checkpoint_id)
302
303 info(f"Checkpoint: pruned '{checkpoint_id}'")
304
305 success(f"Checkpoint: pruned {len(to_remove)} old checkpoints")
306
307
308# State store extensions for checkpoints

Callers

nothing calls this directly

Calls 6

get_state_storeFunction · 0.90
infoFunction · 0.90
successFunction · 0.90
get_checkpointsMethod · 0.80
existsMethod · 0.80
delete_checkpointMethod · 0.80

Tested by

no test coverage detected