Skip to content

Commit a867d0b

Browse files
authored
Fix: Do not initialize a state sync for sqlmesh clean (#5103)
1 parent 41d06a0 commit a867d0b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

sqlmesh/core/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,8 +2537,8 @@ def clear_caches(self) -> None:
25372537
if self.cache_dir.exists():
25382538
rmtree(self.cache_dir)
25392539

2540-
if isinstance(self.state_sync, CachingStateSync):
2541-
self.state_sync.clear_cache()
2540+
if isinstance(self._state_sync, CachingStateSync):
2541+
self._state_sync.clear_cache()
25422542

25432543
def export_state(
25442544
self,

tests/core/test_context.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,9 @@ def test_clear_caches(tmp_path: pathlib.Path):
647647
assert not cache_dir.exists()
648648
assert models_dir.exists()
649649

650+
# Ensure that we don't initialize a CachingStateSync only to clear its (empty) caches
651+
assert context._state_sync is None
652+
650653
# Test clearing caches when cache directory doesn't exist
651654
# This should not raise an exception
652655
context.clear_caches()

0 commit comments

Comments
 (0)