# tinker_cookbook.checkpoint_utils.CheckpointRecord

## _class_ [**tinker_cookbook.checkpoint_utils.CheckpointRecord**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L29)()

A single checkpoint record stored in `checkpoints.jsonl`.

Known fields are exposed as typed attributes. `batch` is optional so
that checkpoint files written by older code (or external tools that use
different progress counters) can still be loaded.

Any additional user-supplied metadata from `loop_state` is preserved in
`extra` so that custom keys round-trip through save/load without
loss.

**Fields:**

- [**name**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L41) ( _str_)
- [**batch**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L42) ( _int | None_, default: `None`)
- [**epoch**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L43) ( _int | None_, default: `None`)
- [**final**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L44) ( _bool | None_, default: `None`)
- [**state_path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L45) ( _str | None_, default: `None`)
- [**sampler_path**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L46) ( _str | None_, default: `None`)
- [**extra**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L47) ( _dict[str, Any]_, default: `field(default_factory=dict)`)

### [**to_dict**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L57)()

Serialize to a dict for JSON storage.

Omits `None` optional fields. Extra metadata keys are merged
into the top-level dict.

**Returns:** _dict[str, Any]_ – JSON-serializable dict with known fields and any extra metadata.

### [**from_dict**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L82)( _d_)

Deserialize from a JSON-parsed dict.

Unknown keys are preserved in `extra` so that downstream
metadata (e.g. `step`) round-trips without loss.

**Parameters:**

- [**d**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L82) ( _dict[str, Any]_) – Dict with at least a "name" key.

**Returns:** _[CheckpointRecord](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/checkpoint_utils/checkpointrecord/)_ – Reconstructed record.

### [**has**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L104)( _key_)

Check whether a field is present (not None), including extra keys.

**Parameters:**

- [**key**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L104) ( _str_) – Field name to check (known attribute or extra key).

**Returns:** _bool_ – True if the field exists and is not `None`.

### [**get**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L117)( _key_, _default_)

Get a field value by name, falling back to extra, then _default_.

This provides uniform access regardless of whether a key is a known
attribute or user-supplied metadata stored in `extra`.

For known fields, returns the attribute value (which may be `None`
if the field is optional and unset). Returns _default_ only when the
key is not a known field **and** is absent from `extra`.

**Parameters:**

- [**key**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L117) ( _str_) – Field name to look up (known attribute or extra key).
- [**default**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/checkpoint_utils.py#L117) ( _Any_) – Value to return if `key` is not a known field and is absent from `extra`. If omitted, returns `None` for missing extra keys.

**Returns:** _Any_ – The field value, extra value, or _default_.

## Referenced by

- [tinker_cookbook.stores.TrainingRunStore.read_checkpoint_records](https://tinker-docs.thinking-machines.ai/cookbook/api-reference/stores/trainingrunstore/#trainingrunstore-read_checkpoint_records)
