checkpointer 2.14.0__tar.gz → 2.14.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.
Files changed (21) hide show
  1. {checkpointer-2.14.0 → checkpointer-2.14.1}/PKG-INFO +1 -1
  2. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/storages/memory_storage.py +6 -0
  3. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/storages/pickle_storage.py +22 -1
  4. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/storages/storage.py +3 -1
  5. {checkpointer-2.14.0 → checkpointer-2.14.1}/pyproject.toml +1 -1
  6. {checkpointer-2.14.0 → checkpointer-2.14.1}/uv.lock +1 -1
  7. {checkpointer-2.14.0 → checkpointer-2.14.1}/.gitignore +0 -0
  8. {checkpointer-2.14.0 → checkpointer-2.14.1}/.python-version +0 -0
  9. {checkpointer-2.14.0 → checkpointer-2.14.1}/ATTRIBUTION.md +0 -0
  10. {checkpointer-2.14.0 → checkpointer-2.14.1}/LICENSE +0 -0
  11. {checkpointer-2.14.0 → checkpointer-2.14.1}/README.md +0 -0
  12. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/__init__.py +0 -0
  13. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/checkpoint.py +0 -0
  14. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/fn_ident.py +0 -0
  15. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/fn_string.py +0 -0
  16. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/import_mappings.py +0 -0
  17. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/object_hash.py +0 -0
  18. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/print_checkpoint.py +0 -0
  19. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/storages/__init__.py +0 -0
  20. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/types.py +0 -0
  21. {checkpointer-2.14.0 → checkpointer-2.14.1}/checkpointer/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: checkpointer
3
- Version: 2.14.0
3
+ Version: 2.14.1
4
4
  Summary: checkpointer adds code-aware caching to Python functions, maintaining correctness and speeding up execution as your code changes.
5
5
  Project-URL: Repository, https://github.com/Reddan/checkpointer.git
6
6
  Author: Hampus Hallman
@@ -35,3 +35,9 @@ class MemoryStorage(Storage):
35
35
  for call_hash, (date, _) in list(calldict.items()):
36
36
  if self.expired_dt(date):
37
37
  del calldict[call_hash]
38
+
39
+ def clear(self):
40
+ fn_path = self.fn_dir().parent
41
+ for key in list(item_map.keys()):
42
+ if key.parent == fn_path:
43
+ del item_map[key]
@@ -7,6 +7,17 @@ from .storage import Storage
7
7
  def filedate(path: Path) -> datetime:
8
8
  return datetime.fromtimestamp(path.stat().st_mtime)
9
9
 
10
+ def empty_dirs(path: Path):
11
+ nonempty_count = 0
12
+ for child in path.iterdir():
13
+ nonempty_count += 1
14
+ if child.is_dir():
15
+ for grand_child in empty_dirs(child):
16
+ yield grand_child
17
+ nonempty_count -= child == grand_child
18
+ if nonempty_count == 0:
19
+ yield path
20
+
10
21
  class PickleStorage(Storage):
11
22
  def get_path(self, call_hash: str):
12
23
  return self.fn_dir() / f"{call_hash[:2]}/{call_hash[2:]}.pkl"
@@ -35,7 +46,7 @@ class PickleStorage(Storage):
35
46
  def cleanup(self, invalidated=True, expired=True):
36
47
  version_path = self.fn_dir()
37
48
  fn_path = version_path.parent
38
- if invalidated:
49
+ if invalidated and fn_path.exists():
39
50
  old_dirs = [path for path in fn_path.iterdir() if path.is_dir() and path != version_path]
40
51
  for path in old_dirs:
41
52
  shutil.rmtree(path)
@@ -47,3 +58,13 @@ class PickleStorage(Storage):
47
58
  count += 1
48
59
  pkl_path.unlink(missing_ok=True)
49
60
  print(f"Removed {count} expired checkpoints for {self.cached_fn.__qualname__}")
61
+ if fn_path.exists():
62
+ for file in fn_path.glob("**/.DS_Store"):
63
+ file.unlink()
64
+ for directory in empty_dirs(fn_path):
65
+ directory.rmdir()
66
+
67
+ def clear(self):
68
+ fn_path = self.fn_dir().parent
69
+ if fn_path.exists():
70
+ shutil.rmtree(fn_path)
@@ -44,4 +44,6 @@ class Storage:
44
44
 
45
45
  def delete(self, call_hash: str) -> None: ...
46
46
 
47
- def cleanup(self, invalidated=True, expired=True): ...
47
+ def cleanup(self, invalidated=True, expired=True) -> None: ...
48
+
49
+ def clear(self) -> None: ...
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "checkpointer"
3
- version = "2.14.0"
3
+ version = "2.14.1"
4
4
  requires-python = ">=3.11"
5
5
  dependencies = []
6
6
  authors = [
@@ -8,7 +8,7 @@ resolution-markers = [
8
8
 
9
9
  [[package]]
10
10
  name = "checkpointer"
11
- version = "2.14.0"
11
+ version = "2.14.1"
12
12
  source = { editable = "." }
13
13
 
14
14
  [package.dev-dependencies]
File without changes
File without changes
File without changes