checkpointer 2.14.3__py3-none-any.whl → 2.14.4__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.
checkpointer/__init__.py CHANGED
@@ -5,6 +5,7 @@ from typing import Callable
5
5
  from .checkpoint import CachedFunction, Checkpointer, CheckpointError, FunctionIdent
6
6
  from .object_hash import ObjectHash
7
7
  from .storages import MemoryStorage, PickleStorage, Storage
8
+ from .storages.memory_storage import cleanup_memory_storage
8
9
  from .types import AwaitableValue, Captured, CapturedOnce, CaptureMe, CaptureMeOnce, HashBy, NoHash
9
10
 
10
11
  checkpoint = Checkpointer()
@@ -1,3 +1,4 @@
1
+ import gc
1
2
  from typing import Any
2
3
  from pathlib import Path
3
4
  from datetime import datetime
@@ -41,3 +42,12 @@ class MemoryStorage(Storage):
41
42
  for key in list(item_map.keys()):
42
43
  if key.parent == fn_path:
43
44
  del item_map[key]
45
+
46
+ def cleanup_memory_storage():
47
+ gc.collect()
48
+ memory_stores = [obj for obj in gc.get_objects() if isinstance(obj, MemoryStorage)]
49
+ storage_keys = {store.fn_dir() for store in memory_stores}
50
+ for key in item_map.keys() - storage_keys:
51
+ del item_map[key]
52
+ for store in memory_stores:
53
+ store.cleanup(invalidated=False)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: checkpointer
3
- Version: 2.14.3
3
+ Version: 2.14.4
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,4 +1,4 @@
1
- checkpointer/__init__.py,sha256=mT706hd-BoTpQXYH_MiqreplONVDvjCWjwwGQ7oRe_8,921
1
+ checkpointer/__init__.py,sha256=lprhgo4BcVbr4RczWdkNIWroVX_9M-akZcMbxOAWHf0,981
2
2
  checkpointer/checkpoint.py,sha256=N3MtNF4Oq3FV69LCfIuyTfNxrcnw9-dGzX312eYigVQ,10454
3
3
  checkpointer/fn_ident.py,sha256=Z2HtkoG8n0ddqNzjejnKW6Lo-ID2unKQZa1tOpRGujs,6911
4
4
  checkpointer/fn_string.py,sha256=YldjAU91cwiZNwuE_AQN_DMiQCPAhGiiC3lPi0uvM0g,2579
@@ -8,11 +8,11 @@ checkpointer/print_checkpoint.py,sha256=uUQ493fJCaB4nhp4Ox60govSCiBTIPbBX15zt2Qi
8
8
  checkpointer/types.py,sha256=GFqbGACdDxzQX3bb2LmF9UxQVWOEisGvdtobnqCBAOA,1129
9
9
  checkpointer/utils.py,sha256=BAv_qvcanbYqgr7cCOCKNiG0_rGbNbLomBbpvoYlltc,3553
10
10
  checkpointer/storages/__init__.py,sha256=p-r4YrPXn505_S3qLrSXHSlsEtb13w_DFnCt9IiUomk,296
11
- checkpointer/storages/memory_storage.py,sha256=1YHZU-WSqvLA_0og53UZY141ziDgnaBub2mDjDaeAj8,1261
11
+ checkpointer/storages/memory_storage.py,sha256=VmU7uDscuibqpxIb0F3FRUXncVEbAOrLv-VaquP8Bsk,1598
12
12
  checkpointer/storages/pickle_storage.py,sha256=WCbWGdDH046_GrlnttcqqGZ55wGOz2Rb7Gu0slI448g,2203
13
13
  checkpointer/storages/storage.py,sha256=JVxdq1DMhbq83bvflvIuW7okE1CQCa7poQPsj3x0ACg,1366
14
- checkpointer-2.14.3.dist-info/METADATA,sha256=YehES3ivV7IqJfs3jKVNCfrgRZwdEySFJrwqem8MVPo,11215
15
- checkpointer-2.14.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- checkpointer-2.14.3.dist-info/licenses/ATTRIBUTION.md,sha256=WF6L7-sD4s9t9ytVJOhjhpDoZ6TrWpqE3_bMdDIeJxI,1078
17
- checkpointer-2.14.3.dist-info/licenses/LICENSE,sha256=drXs6vIb7uW49r70UuMz2A1VtOCl626kiTbcmrar1Xo,1072
18
- checkpointer-2.14.3.dist-info/RECORD,,
14
+ checkpointer-2.14.4.dist-info/METADATA,sha256=AoUxO7FgKWaEIeQD7sOIeFN5d1FkxzdMMSvMn8j23WU,11215
15
+ checkpointer-2.14.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ checkpointer-2.14.4.dist-info/licenses/ATTRIBUTION.md,sha256=WF6L7-sD4s9t9ytVJOhjhpDoZ6TrWpqE3_bMdDIeJxI,1078
17
+ checkpointer-2.14.4.dist-info/licenses/LICENSE,sha256=drXs6vIb7uW49r70UuMz2A1VtOCl626kiTbcmrar1Xo,1072
18
+ checkpointer-2.14.4.dist-info/RECORD,,