tinker_cookbook.checkpoint_utils.CheckpointRecord
class tinker_cookbook.checkpoint_utils.CheckpointRecord(**)
A single checkpoint record stored in checkpoints.jsonl.
Fields:
- name (str)
- batch (int | None) – Default:
None - epoch (int | None) – Default:
None - final (bool | None) – Default:
None - state_path (str | None) – Default:
None - sampler_path (str | None) – Default:
None - extra (dict[str, Any]) – Default:
field(default_factory=dict)
to_dict()
Serialize to a dict for JSON storage.
Returns: dict[str, Any]: JSON-serializable dict with known fields and any extra metadata.
from_dict(d)
Deserialize from a JSON-parsed dict.
Parameters:
- d (dict[str, Any]) – Dict with at least a
"name"key.
Returns: CheckpointRecord: Reconstructed record.
has(key)
Check whether a field is present (not None), including extra keys.
Parameters:
- key (str) – Field name to check (known attribute or extra key).
Returns: bool: True if the field exists and is not None.
get(key, default)
Get a field value by name, falling back to extra, then default.
Parameters:
- key (str) – Field name to look up (known attribute or extra key).
- default (Any) – Value to return if
keyis not a known field and is absent from :attr:extra. If omitted, returnsNonefor missing extra keys.
Returns: Any: The field value, extra value, or default.