Skip to content

Feat: Add support for configurable cache directory#4869

Merged
themisvaltinos merged 3 commits intomainfrom
themis/cache
Jul 2, 2025
Merged

Feat: Add support for configurable cache directory#4869
themisvaltinos merged 3 commits intomainfrom
themis/cache

Conversation

@themisvaltinos
Copy link
Copy Markdown
Collaborator

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

Comment thread tests/core/test_context.py Outdated
)
),
model_defaults=model_defaults,
cache_dir="{custom_cache_dir}",
Copy link
Copy Markdown
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
Copy Markdown
Collaborator 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
Copy Markdown
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?

Comment thread sqlmesh/core/config/scheduler.py Outdated
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
Copy Markdown
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
Copy Markdown
Collaborator 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