checkpointer 2.14.5__py3-none-any.whl → 2.14.6__py3-none-any.whl

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.
@@ -263,6 +263,9 @@ class CachedFunction(Generic[Fn]):
263
263
  def set(self, value, *args, **kw):
264
264
  self.storage.store(self._get_call_hash(args, kw), value)
265
265
 
266
+ def set_awaitable(self: CachedFunction[Callable[P, Coro[R]]], value: R, *args: P.args, **kw: P.kwargs):
267
+ self.set(AwaitableValue(value), *args, **kw)
268
+
266
269
  def __repr__(self) -> str:
267
270
  initialized = "fn_hash" in self.ident.__dict__
268
271
  fn_hash = self.ident.fn_hash[:6] if initialized else "- uninitialized"
@@ -53,7 +53,8 @@ class PickleStorage(Storage):
53
53
  if invalidated and fn_path.exists():
54
54
  old_dirs = [path for path in fn_path.iterdir() if path.is_dir() and path != version_path]
55
55
  for path in old_dirs:
56
- shutil.rmtree(path)
56
+ for pkl_path in path.glob("**/*.pkl"):
57
+ pkl_path.unlink(missing_ok=True)
57
58
  if old_dirs:
58
59
  print(f"Removed {len(old_dirs)} invalidated directories for {self.cached_fn.__qualname__}")
59
60
  if expired and self.checkpointer.expiry:
@@ -22,7 +22,7 @@ class Storage:
22
22
  return self.checkpointer.directory / self.fn_id()
23
23
 
24
24
  def expired(self, call_hash: str) -> bool:
25
- if not self.checkpointer.expiry:
25
+ if self.checkpointer.expiry is None:
26
26
  return False
27
27
  return self.expired_dt(self.checkpoint_date(call_hash))
28
28
 
checkpointer/utils.py CHANGED
@@ -121,15 +121,15 @@ def empty_dirs(path: Path) -> Iterable[Path]:
121
121
  for child in path.iterdir():
122
122
  nonempty_count += 1
123
123
  if child.is_dir():
124
- for grand_child in empty_dirs(child):
125
- yield grand_child
126
- nonempty_count -= child == grand_child
124
+ for descendant in empty_dirs(child):
125
+ yield descendant
126
+ nonempty_count -= child == descendant
127
127
  if nonempty_count == 0:
128
128
  yield path
129
129
 
130
130
  def clear_directory(path: Path):
131
131
  if path.is_dir():
132
132
  for file in path.glob("**/.DS_Store"):
133
- file.unlink()
133
+ file.unlink(missing_ok=True)
134
134
  for directory in empty_dirs(path):
135
135
  directory.rmdir()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: checkpointer
3
- Version: 2.14.5
3
+ Version: 2.14.6
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
@@ -1,18 +1,18 @@
1
1
  checkpointer/__init__.py,sha256=lprhgo4BcVbr4RczWdkNIWroVX_9M-akZcMbxOAWHf0,981
2
- checkpointer/checkpoint.py,sha256=Vw0uKPBtp01Rit-ydE28TrMO3t3HQ2dkT0uJT2gtyms,10509
2
+ checkpointer/checkpoint.py,sha256=BG2LkBbnCxWAzSTCNdYFJElef7LIFu29MvZqRp0RFrc,10665
3
3
  checkpointer/fn_ident.py,sha256=Z2HtkoG8n0ddqNzjejnKW6Lo-ID2unKQZa1tOpRGujs,6911
4
4
  checkpointer/fn_string.py,sha256=YldjAU91cwiZNwuE_AQN_DMiQCPAhGiiC3lPi0uvM0g,2579
5
5
  checkpointer/import_mappings.py,sha256=ESqWvZTzYAmaVnJ6NulUvn3_8CInOOPmEKUXO2WD_WA,1794
6
6
  checkpointer/object_hash.py,sha256=_VgyTEoe3H6268KBAOFZxSgWHb6otgG-3NzhHyehxe4,8595
7
7
  checkpointer/print_checkpoint.py,sha256=uUQ493fJCaB4nhp4Ox60govSCiBTIPbBX15zt2QiRGo,1356
8
8
  checkpointer/types.py,sha256=GFqbGACdDxzQX3bb2LmF9UxQVWOEisGvdtobnqCBAOA,1129
9
- checkpointer/utils.py,sha256=BAv_qvcanbYqgr7cCOCKNiG0_rGbNbLomBbpvoYlltc,3553
9
+ checkpointer/utils.py,sha256=WGfVeHeZua010YXMuDPwAYfyQyB6k2bm0n0nbZdJ28Q,3565
10
10
  checkpointer/storages/__init__.py,sha256=p-r4YrPXn505_S3qLrSXHSlsEtb13w_DFnCt9IiUomk,296
11
11
  checkpointer/storages/memory_storage.py,sha256=M5O3gRMHBiG3CgMcFdA6-iDGvfafKqTi9nN3u8sETCg,1801
12
- checkpointer/storages/pickle_storage.py,sha256=3_it1YQL6y2WQwnOHT_UPZ1BQkVJZvuR9txcuiuPwYQ,2242
13
- checkpointer/storages/storage.py,sha256=0dwxQvg0HXlgU93FRXrpZnF_Qb6-KE0WyWhS_GJmmm0,1366
14
- checkpointer-2.14.5.dist-info/METADATA,sha256=vNYVwNi98WgyKujBVSLhnkWqsx3VMo7KHhgOiWe-i9w,11215
15
- checkpointer-2.14.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- checkpointer-2.14.5.dist-info/licenses/ATTRIBUTION.md,sha256=WF6L7-sD4s9t9ytVJOhjhpDoZ6TrWpqE3_bMdDIeJxI,1078
17
- checkpointer-2.14.5.dist-info/licenses/LICENSE,sha256=drXs6vIb7uW49r70UuMz2A1VtOCl626kiTbcmrar1Xo,1072
18
- checkpointer-2.14.5.dist-info/RECORD,,
12
+ checkpointer/storages/pickle_storage.py,sha256=L6E7cugbn-XGMMlcHCFBJ-rBLbmtzbiPwRrlgfRd7yc,2304
13
+ checkpointer/storages/storage.py,sha256=5v_9Mp8__oqPnyrGsUEiT7jU4eMk9L4ORHDZeQw-TU4,1370
14
+ checkpointer-2.14.6.dist-info/METADATA,sha256=q-QYZcNIAkQ-3AcnIuKaXtifxwlIqYPU3vy86gTFGBQ,11215
15
+ checkpointer-2.14.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ checkpointer-2.14.6.dist-info/licenses/ATTRIBUTION.md,sha256=WF6L7-sD4s9t9ytVJOhjhpDoZ6TrWpqE3_bMdDIeJxI,1078
17
+ checkpointer-2.14.6.dist-info/licenses/LICENSE,sha256=drXs6vIb7uW49r70UuMz2A1VtOCl626kiTbcmrar1Xo,1072
18
+ checkpointer-2.14.6.dist-info/RECORD,,