# 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/) (sync) and [`AsyncStorage`](https://tinker-docs.thinking-machines.ai/cookbook/api-reference/stores/asyncstorage/) (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/) \| 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.thinking-machines.ai/cookbook/api-reference/stores/storagestat/) \| 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)
