Skip to content

Feat: Add support for configurable cache directory #4869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 2, 2025
Merged

Conversation

themisvaltinos
Copy link
Contributor

By default SQLMesh stores its cache in a .cache folder inside the project directory. This introduces a configuration option to specify a custom cache location, either as a relative path or an absolute path. Fixes: #4307

# Relative path to project directory
cache_dir: .my_custom_cache

# Absolute path
cache_dir: /tmp/sqlmesh_cache

)
),
model_defaults=model_defaults,
cache_dir="{custom_cache_dir}",
Copy link
Collaborator

@erindru erindru Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think injecting the path as a quoted string here is breaking the tests on Windows, because it ends up being cache_dir="C:\some\path" and the \ is treated as an escape

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks you’re right updated the test to use as posix to have forward slashes in all platforms

Copy link
Collaborator

@erindru erindru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, this will definitely help in Notebook environments (Fabric in particular) which limit the number of files in the persistent storage.

I notice that cache_dir vs cache_path is used a bit inconsistently though? Should it be one or the other?

@@ -105,7 +105,7 @@ def create_state_sync(self, context: GenericContext) -> StateSync:

schema = context.config.get_state_schema(context.gateway)
return EngineAdapterStateSync(
engine_adapter, schema=schema, context_path=context.path, console=context.console
engine_adapter, schema=schema, context_path=context.cache_dir, console=context.console
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the context_path parameter be renamed to cache_dir?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes good point renamed to use the cache_dir name here and everywhere else that I was using cache_path for consistency

@themisvaltinos themisvaltinos merged commit fcfbe8f into main Jul 2, 2025
27 checks passed
@themisvaltinos themisvaltinos deleted the themis/cache branch July 2, 2025 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make cache directory location configurable
2 participants