# tinker_cookbook.stores.LocalStorage ## *class* [**tinker_cookbook.stores.LocalStorage**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L207)() File-based storage rooted at a local directory. Implements both [`Storage`](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/stores/storage/index.md) (sync) and [`AsyncStorage`](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/stores/asyncstorage/index.md) (via `to_thread`). Pickle-serializable (stores only a `Path`). ### *property* [**root**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L220) The resolved local directory root. **Returns:** *Path* ### [**url**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L224)(*path*) Return a `file:///` URI for the given path. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L224) (*str*) **Returns:** *str* ### [**read**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L237)(*path*) See `Storage.read`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L237) (*str*) **Returns:** *bytes* ### [**write**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L241)(*path*, *data*) See `Storage.write`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L241) (*str*) - [**data**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L241) (*bytes*) **Returns:** *None* ### [**append**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L247)(*path*, *data*) See `Storage.append`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L247) (*str*) - [**data**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L247) (*bytes*) **Returns:** *None* ### [**exists**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L254)(*path*) See `Storage.exists`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L254) (*str*) **Returns:** *bool* ### [**stat**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L258)(*path*) See `Storage.stat`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L258) (*str*) **Returns:** *[StorageStat](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/stores/storagestat/index.md) | None* ### [**read_range**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L266)(*path*, *offset*, *length*) See `Storage.read_range`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L266) (*str*) - [**offset**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L266) (*int*) - [**length**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L266) (*int | None*) **Returns:** *bytes* ### [**list_dir**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L272)(*prefix*) See `Storage.list_dir`. Returns sorted names. **Parameters:** - [**prefix**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L272) (*str*) **Returns:** *list[str]* ### [**remove**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L279)(*path*) See `Storage.remove`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L279) (*str*) **Returns:** *None* ### [**remove_dir**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L284)(*path*) See `Storage.remove_dir`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L284) (*str*) **Returns:** *None* ### [**flush**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L290)() See `Storage.flush`. No-op for local filesystem. **Returns:** *None* ### [**aread**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L302)(*path*) Async version of `read`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L302) (*str*) **Returns:** *bytes* ### [**awrite**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L306)(*path*, *data*) Async version of `write`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L306) (*str*) - [**data**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L306) (*bytes*) **Returns:** *None* ### [**aappend**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L310)(*path*, *data*) Async version of `append`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L310) (*str*) - [**data**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L310) (*bytes*) **Returns:** *None* ### [**aexists**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L314)(*path*) Async version of `exists`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L314) (*str*) **Returns:** *bool* ### [**astat**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L318)(*path*) Async version of `stat`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L318) (*str*) **Returns:** *[StorageStat](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/stores/storagestat/index.md) | None* ### [**aread_range**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L322)(*path*, *offset*, *length*) Async version of `read_range`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L322) (*str*) - [**offset**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L322) (*int*) - [**length**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L322) (*int | None*) **Returns:** *bytes* ### [**alist_dir**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L326)(*prefix*) Async version of `list_dir`. **Parameters:** - [**prefix**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L326) (*str*) **Returns:** *list[str]* ### [**aremove**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L330)(*path*) Async version of `remove`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L330) (*str*) **Returns:** *None* ### [**aremove_dir**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L334)(*path*) Async version of `remove_dir`. **Parameters:** - [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/storage.py#L334) (*str*) **Returns:** *None* ## Referenced by - [tinker_cookbook.stores.Storage.flush](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/stores/storage/#storage-flush)