UdasriHasindu commited on
Commit
66eca06
·
1 Parent(s): bb3469b

prevent deleting runs/outputs dir

Browse files
Files changed (1) hide show
  1. scripts/cleanup_runs.py +5 -1
scripts/cleanup_runs.py CHANGED
@@ -63,8 +63,12 @@ def cleanup_runs(root: Path, max_age_minutes: float, dry_run: bool = False) -> t
63
  except PermissionError:
64
  print(f"[WARN] Permission denied: {file_path}")
65
 
66
- # Remove empty directories bottom-up (excluding root)
 
67
  for dir_path in sorted((p for p in root.rglob("*") if p.is_dir()), key=lambda p: len(p.parts), reverse=True):
 
 
 
68
  try:
69
  if any(dir_path.iterdir()):
70
  continue
 
63
  except PermissionError:
64
  print(f"[WARN] Permission denied: {file_path}")
65
 
66
+ # Remove empty subdirectories bottom-up (excluding root and outputs/)
67
+ preserve_dirs = {root, root / "outputs"}
68
  for dir_path in sorted((p for p in root.rglob("*") if p.is_dir()), key=lambda p: len(p.parts), reverse=True):
69
+ # Skip preserving root structure
70
+ if dir_path in preserve_dirs or dir_path.parent in preserve_dirs:
71
+ continue
72
  try:
73
  if any(dir_path.iterdir()):
74
  continue