# tinker_cookbook.stores.TrainingRunStore

## _class_ [**tinker_cookbook.stores.TrainingRunStore**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L50)()

Typed read/write access to one training run's data.

All file I/O goes through the [`Storage`](https://tinker-docs.thinking-machines.ai/cookbook/api-reference/stores/storage/) protocol — no direct `Path`/`open()` usage. Pickle-serializable when freshly constructed (lazy reader init).

### [**url**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L67)( _path_)

Return a human-readable URI for a path within this run.

Useful for logging in distributed workers:

```python
logger.info("Writing metrics to %s", store.url("metrics.jsonl"))
```

**Parameters:**

- [**path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L67) ( _str_)

**Returns:** _str_

### [**read_config**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L128)()

Read config.json (cached after first read).

**Returns:** _dict[str, Any] | None_

### [**read_metrics**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L142)()

Read all metrics (incremental — only new data from disk).

**Returns:** _list[dict[str, Any]]_

### [**read_new_metrics**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L148)()

Read only metrics added since last call.

**Returns:** _list[dict[str, Any]]_

### [**metric_keys**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L152)()

All metric keys seen so far (excluding 'step').

**Returns:** _set[str]_

### [**read_rollouts**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L162)( _iteration_, _base_name_)

Read rollout summaries for an iteration as raw dicts.

**Parameters:**

- [**iteration**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L162) ( _int_) – Training iteration number.
- [**base_name**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L162) ( _str_) – Prefix for the JSONL file (e.g. "train", "eval_gsm8k"). Matches the naming used by `rollout_summaries_jsonl_path()` in RL training.

**Returns:** _list[dict[str, Any]]_

### [**read_single_rollout**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L180)( _iteration_, _group_idx_, _traj_idx_, _base_name_)

Find one rollout by group and trajectory index, or `None`.

**Parameters:**

- [**iteration**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L182) ( _int_)
- [**group_idx**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L183) ( _int_)
- [**traj_idx**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L184) ( _int_)
- [**base_name**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L185) ( _str_)

**Returns:** _dict[str, Any] | None_

### [**read_checkpoints**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L195)()

Read checkpoints.jsonl.

**Returns:** _list[dict[str, Any]]_

### [**read_checkpoint_records**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L199)()

Read checkpoints.jsonl as [`CheckpointRecord`](https://tinker-docs.thinking-machines.ai/cookbook/api-reference/checkpoint_utils/checkpointrecord/) objects.

**Returns:** _list[Any]_

### [**read_timing**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L212)()

Read all timing records (incremental — only new data from disk).

**Returns:** _list[dict[str, Any]]_

### [**read_logtree**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L220)( _iteration_, _base_name_)

Read a logtree JSON file for an iteration, or `None` if missing.

**Parameters:**

- [**iteration**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L220) ( _int_)
- [**base_name**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L220) ( _str_)

**Returns:** _dict[str, Any] | None_

### [**list_logtrees**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L224)( _iteration_)

List logtree base names for an iteration (e.g. ["train", "eval_gsm8k"]).

**Parameters:**

- [**iteration**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L224) ( _int_)

**Returns:** _list[str]_

### [**list_iterations**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L231)()

List all iteration directories with metadata about their contents.

**Returns:** _list[IterationInfo]_

### [**write_config**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L259)( _config_)

Write config.json (overwrites if exists, updates cache).

**Parameters:**

- [**config**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L259) ( _dict[str, Any]_)

**Returns:** _None_

### [**write_metrics**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L264)( _metrics_, _step_)

Append one metrics record to metrics.jsonl.

The record is `{\"step\": step, ...metrics}` if step is given, otherwise just the metrics dict.

**Parameters:**

- [**metrics**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L264) ( _dict[str, Any]_)  
- [**step**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L264) ( _int | None_)

**Returns:** _None_

### [**write_timing_spans**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L274)( _step_, _spans_)

Append one timing record to timing_spans.jsonl.

Each span dict should have keys: `name`, `duration`, `wall_start`, `wall_end`.

**Parameters:**

- [**step**](https://github.com/thinking-machines-lab/tinker_cookbook/blob/main/tinker_cookbook/stores/training_store.py#L274) ( _int_)
- [**spans**](https://github.com/thinking-machines-lab/tinker_cookbook/blob/main/tinker_cookbook/stores/training_store.py#L274) ( _list[dict[str, Any]]_)

**Returns:** _None_

### [**write_checkpoint**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L284)( _record_)

Append one checkpoint record to checkpoints.jsonl.

Accepts a raw dict (e.g. from `CheckpointRecord.to_dict()`).
Must contain at least a "name" key.

**Parameters:**

- [**record**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L284) ( _dict[str, Any]_)

**Returns:** _None_

### [**write_rollouts**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L292)( _iteration_, _records_, _base_name_)

Write rollout summaries for an iteration (overwrites).

**Parameters:**

- [**iteration**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L294) ( _int_) – Training iteration number.
- [**records**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L295) ( _list[dict[str, Any]]_) – List of trajectory dicts to write.
- [**base_name**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L296) ( _str_) – Prefix for the JSONL file (e.g. "train", "eval_gsm8k"). Must match the `base_name` used in `read_rollouts()`.

**Returns:** _None_

### [**write_logtree**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L316)( _iteration_, _data_, _base_name_)

Write a logtree JSON file for an iteration (overwrites).

**Parameters:**

- [**iteration**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L316) ( _int_)
- [**data**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L316) ( _dict[str, Any]_) 
- [**base_name**](https://github.com/thinking-machines-lab/tinker_cookbook/blob/main/tinker_cookbook/stores/training_store.py#L316) ( _str_)

**Returns:** _None_

### [**write_code_diff**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L320)( _diff_)

Write code.diff (overwrites).

**Parameters:**

- [**diff**](https://github.com/thinking-machines-lab/tinker_cookbook/blob/main/tinker_cookbook/stores/training_store.py#L320) ( _str_)

**Returns:** _None_

### [**aread_config**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L326)()

Async version of `read_config`.

**Returns:** _dict[str, Any] | None_

### [**aread_metrics**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L330)()

Async version of `read_metrics`.

**Returns:** _list[dict[str, Any]]_

### [**aread_new_metrics**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L334)()

Async version of `read_new_metrics`.

**Returns:** _list[dict[str, Any]]_

### [**aread_rollouts**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L338)( _iteration_, _base_name_)

Async version of `read_rollouts`.

**Parameters:**

- [**iteration**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L339) ( _int_)
- [**base_name**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L339) ( _str_)

**Returns:** _list[dict[str, Any]]_

### [**aread_checkpoints**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L344)()

Async version of `read_checkpoints`.

**Returns:** _list[dict[str, Any]]_

### [**aread_timing**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L348)()

Async version of `read_timing`.

**Returns:** _list[dict[str, Any]]_

### [**aread_logtree**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L352)( _iteration_, _base_name_)

Async version of `read_logtree`.

**Parameters:**

- [**iteration**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L353) ( _int_)
- [**base_name**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L353) ( _str_)

**Returns:** _dict[str, Any] | None_

### [**awrite_metrics**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L358)( _metrics_, _step_)

Async version of `write_metrics`.

**Parameters:**

- [**metrics**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L358) ( _dict[str, Any]_) 
- [**step**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L358) ( _int | None_)

**Returns:** _None_

### [**awrite_checkpoint**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L362)( _record_)

Async version of `write_checkpoint`.

**Parameters:**

- [**record**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/stores/training_store.py#L362) ( _dict[str, Any]_)

**Returns:** _None_

## Referenced by

- [tinker_cookbook.checkpoint_utils.save_checkpoint](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/checkpoint_utils/save_checkpoint/)
- [tinker_cookbook.stores.IncrementalReader](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/stores/incrementalreader/)
- [tinker_cookbook.stores.RunRegistry.get_training_store](https://tinker-docs.thinking-machines.ai/cookbook/api-reference/stores/runregistry/#runregistry-get_training_store)
