Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sqlmesh/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2537,8 +2537,8 @@ def clear_caches(self) -> None:
if self.cache_dir.exists():
rmtree(self.cache_dir)

if isinstance(self.state_sync, CachingStateSync):
self.state_sync.clear_cache()
if isinstance(self._state_sync, CachingStateSync):
self._state_sync.clear_cache()

def export_state(
self,
Expand Down
3 changes: 3 additions & 0 deletions tests/core/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,9 @@ def test_clear_caches(tmp_path: pathlib.Path):
assert not cache_dir.exists()
assert models_dir.exists()

# Ensure that we don't initialize a CachingStateSync only to clear its (empty) caches
assert context._state_sync is None

# Test clearing caches when cache directory doesn't exist
# This should not raise an exception
context.clear_caches()
Expand Down