teff.checkpoint.history¶
teff.checkpoint.history
¶
Time-travel checkpoints: keep every per-iteration snapshot.
A plain :class:~teff.checkpoint.SQLiteCheckpointer / PGCheckpointer
overwrites its row on every save, so only the latest snapshot of a run
survives. Time travel needs the full history: one checkpoint per node
execution (keyed by iteration), so a run can be rewound to any earlier
moment, edited, and replayed.
This module adds a checkpoint_history table holding every snapshot a
checkpointer ever saved for a (owner, checkpoint_id). The shared
:class:_HistoryMixin implements save/history/load_at; each
backend (:class:SQLiteHistoryCheckpointer, :class:PGHistoryCheckpointer)
mixes it with the plain checkpointer and supplies the storage dialect.
Classes:
| Name | Description |
|---|---|
PGHistoryCheckpointer |
PostgreSQL checkpointer that also keeps the full per-step history. |
SQLiteHistoryCheckpointer |
SQLite checkpointer that also keeps the full per-step history. |
PGHistoryCheckpointer
¶
Bases: _HistoryMixin, PGCheckpointer
PostgreSQL checkpointer that also keeps the full per-step history.
Requires asyncpg (install via teff[pg-checkpoint]). Mirrors
:class:PGCheckpointer but appends every save to a
checkpoint_history table, exposing history / load_at for
time travel in production.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dsn
|
str
|
PostgreSQL connection string. |
required |
table
|
str
|
Table name for the current checkpoints (default
|
'checkpoints'
|
Source code in teff/checkpoint/history.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
SQLiteHistoryCheckpointer
¶
Bases: _HistoryMixin, SQLiteCheckpointer
SQLite checkpointer that also keeps the full per-step history.
A drop-in for :class:teff.checkpoint.SQLiteCheckpointer that, on every
save, additionally appends the snapshot to a checkpoint_history
table — so the current checkpoint can be overwritten without losing the
earlier ones. history / load_at expose the timeline for time
travel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the SQLite database file. |
required |
Source code in teff/checkpoint/history.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |