fleche.storage.bagofholding_file ================================ .. py:module:: fleche.storage.bagofholding_file Attributes ---------- .. autoapisummary:: fleche.storage.bagofholding_file.logger fleche.storage.bagofholding_file.VersionValidator Classes ------- .. autoapisummary:: fleche.storage.bagofholding_file.BagOfHoldingH5FileBackend fleche.storage.bagofholding_file.ValueBagOfHoldingH5File fleche.storage.bagofholding_file.CallBagOfHoldingH5File Module Contents --------------- .. py:data:: logger .. py:data:: VersionValidator .. py:class:: BagOfHoldingH5FileBackend Bases: :py:obj:`fleche.storage.file.FileStorage` File-based storage backend using pickle. Stores objects on the filesystem. .. py:attribute:: version_validator :type: VersionValidator | None :value: None .. py:method:: __post_init__() .. py:method:: _to_file(value: Any, path: pathlib.Path) -> None .. py:method:: _from_file(path: pathlib.Path) -> Any .. py:method:: rebag(version_validator: VersionValidator = 'none') -> None Re-open and re-save all bags using the given version validator. Useful when bags were created with an older library version and would otherwise fail strict version checking on load. .. py:class:: ValueBagOfHoldingH5File Bases: :py:obj:`fleche.storage.thread_safe.PerKeyLockMixin`, :py:obj:`fleche.storage.destructuring.DestructuringMixin`, :py:obj:`fleche.storage.base.ValueMixin`, :py:obj:`BagOfHoldingH5FileBackend` Mixin that locks per-key so concurrent ops on different keys proceed in parallel. A lightweight ``threading.Lock`` guards the lock-table itself; once the per-key ``RLock`` is obtained the table lock is released, so two threads operating on *different* keys never block each other. Operations on the *same* key are serialized by the per-key lock, which is reentrant to allow nested calls (e.g. ``expand`` inside ``load``). Instances must be hashable. Place before the concrete storage class in the MRO:: @dataclass(frozen=True) class PerKeyValuePickle(PerKeyLockMixin, ValuePickleFile): ... .. py:class:: CallBagOfHoldingH5File Bases: :py:obj:`fleche.storage.thread_safe.PerKeyLockMixin`, :py:obj:`fleche.storage.base.CallMixin`, :py:obj:`BagOfHoldingH5FileBackend` Mixin that locks per-key so concurrent ops on different keys proceed in parallel. A lightweight ``threading.Lock`` guards the lock-table itself; once the per-key ``RLock`` is obtained the table lock is released, so two threads operating on *different* keys never block each other. Operations on the *same* key are serialized by the per-key lock, which is reentrant to allow nested calls (e.g. ``expand`` inside ``load``). Instances must be hashable. Place before the concrete storage class in the MRO:: @dataclass(frozen=True) class PerKeyValuePickle(PerKeyLockMixin, ValuePickleFile): ...