# 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/index.md)* – 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.thinkingmachines.ai/cookbook/api-reference/stores/trainingrunstore/#trainingrunstore-read_checkpoint_records)