Commit 82e0487
committed
feat: add load_state flag to Context
Add `load_state: bool = True` to `GenericContext.__init__` and AND the
new flag into the two `if any(self._projects):` guards in
`Context.load()`. With `load_state=False`, no remote-snapshot merge
runs, so `state_reader` is never read and the state-sync backend is
never instantiated.
The default preserves today's behavior for every existing caller. CLI
wiring lands in the next commit; this one just introduces the
mechanism and proves it.
Tests patch `EngineAdapterStateSync.get_versions` to raise and assert
it is never called when `load_state=False`. They set a non-empty
`project` on the test config so `any(self._projects)` is truthy and
the gate actually exercises `self._load_state` (with the default
empty project, the outer `any(...)` short-circuits and the test is
vacuous). Verified non-vacuous by flipping `load_state=True` and
confirming both tests fail with the patched RuntimeError.
The plan originally proposed an unreachable Postgres state
connection; `psycopg2` is not installed in the dev env so
`PostgresConnectionConfig` validates at construction time and the
config can't be built. Implementation uses the plan's documented
patch-based fallback instead. Plan updated to reflect the change.
Coding-Agent: pi
Model: anthropic/claude-sonnet-4-6
Signed-off-by: Joe Hartshorn <8881940+j-hartshorn@users.noreply.github.com>1 parent 15bf65b commit 82e0487
4 files changed
Lines changed: 58 additions & 7 deletions
File tree
- docs/2026-05-21_local-only-format
- sqlmesh/core
- tests/core
- linter
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | | - | |
35 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | | - | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | | - | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| 366 | + | |
366 | 367 | | |
367 | 368 | | |
368 | 369 | | |
| |||
383 | 384 | | |
384 | 385 | | |
385 | 386 | | |
| 387 | + | |
386 | 388 | | |
387 | 389 | | |
388 | 390 | | |
| |||
413 | 415 | | |
414 | 416 | | |
415 | 417 | | |
| 418 | + | |
416 | 419 | | |
417 | 420 | | |
418 | 421 | | |
| |||
674 | 677 | | |
675 | 678 | | |
676 | 679 | | |
677 | | - | |
| 680 | + | |
678 | 681 | | |
679 | 682 | | |
680 | 683 | | |
| |||
684 | 687 | | |
685 | 688 | | |
686 | 689 | | |
687 | | - | |
| 690 | + | |
688 | 691 | | |
689 | 692 | | |
690 | 693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 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 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
0 commit comments