squirrel.store.filesystem
¶
Module Contents¶
Classes¶
Store that uses fsspec to read from / write to files. |
Functions¶
|
Generates a random key |
-
class
squirrel.store.filesystem.
FilesystemStore
(url: str, serializer: Optional[squirrel.serialization.SquirrelSerializer] = None, clean: bool = False, **storage_options)¶ Bases:
squirrel.store.store.AbstractStore
Store that uses fsspec to read from / write to files.
Initializes FilesystemStore.
- Parameters
url (str) – Path to the root directory. If this path does not exist, it will be created.
serializer (SquirrelSerializer, optional) – Serializer that is used to serialize data before persisting (see
set()
) and to deserialize data after reading (seeget()
). If not specified, data will not be (de)serialized. Defaults to None.clean (bool) – If true, all files in the store will be removed recursively
**storage_options – Keyword arguments passed to filesystem initializer.
-
get
(key: str, mode: str = 'rb', **open_kwargs) → Any¶ Yields the item with the given key.
If the store has a serializer, data read from the file will be deserialized.
-
keys
(nested: bool = True, **kwargs) → Iterator[str]¶ Yields all paths in the store, relative to the root directory.
Paths are generated using
squirrel.iterstream.source.FilePathGenerator
.- Parameters
nested (bool) – Whether to return paths that are not direct children of the root directory. If True, all paths in the store will be yielded. Otherwise, only the top-level paths (i.e. direct children of the root path) will be yielded. This option is passed to FilePathGenerator initializer. Defaults to True.
**kwargs – Other keyword arguments passed to the FilePathGenerator initializer. If a key is present in both kwargs and self.storage_options, the value from kwargs will be used.
- Yields
(str) Paths to files and directories in the store relative to the root directory.