-
Notifications
You must be signed in to change notification settings - Fork 72
Add an SQL core #267
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
Add an SQL core #267
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
69c38a0
Add an SQL core
shaypal5 54dd1e7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 697dffe
black and flake8
shaypal5 c3ae27e
tests for sql core
shaypal5 9db0462
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4c72d4b
only test sql backend on ubuntu currently
shaypal5 1def4a6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c1ce97f
more fixes
shaypal5 39617bc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 2068cb2
more linting nightmare
shaypal5 78272af
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e46ae73
more error fixin
shaypal5 ca8fec8
install sql deps only for sql backend tests
shaypal5 83a229a
no import warning on sql core imports
shaypal5 2e0554f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7c9a195
more sql core tests
shaypal5 0e3103b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 21f666f
fixes and linting
shaypal5 4cd1f13
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a63ef15
test fixes and more copilot instructions
shaypal5 2406107
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6f600aa
more fixes
shaypal5 c5fcea2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c3bab1c
fix pytest arg to run only local tests
shaypal5 9a3ce3b
fix var name
shaypal5 36f0d8e
a couple more sql core tests
shaypal5 15ce02e
addressing copilot comments
shaypal5 5d29cda
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3cef55e
remove evil lines from pyproject.toml
shaypal5 bf76240
fix test_sqlcore_set_entry_fallback
shaypal5 8022be6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 23b3d27
readme note fix
shaypal5 733d578
pylint and flake8 be gone
shaypal5 e3f38cb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 311decb
Update README.rst
shaypal5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,59 @@ | ||
| # GitHub Copilot Custom Instructions for Cachier | ||
| # Copilot Instructions for Cachier | ||
|
|
||
| - Cachier is a Python package providing persistent, stale-free memoization decorators for Python functions, supporting local (pickle), cross-machine (MongoDB), and in-memory caching backends. | ||
| - Always refer to the main decorator as `@cachier`, and note that it can be configured via parameters such as `stale_after`, `backend`, `mongetter`, `cache_dir`, `pickle_reload`, `separate_files`, `wait_for_calc_timeout`, and `allow_none`. | ||
| - Arguments to cached functions must be hashable; custom hash functions can be provided via the `hash_func` parameter for unhashable arguments. | ||
| Welcome to the Cachier codebase! Please follow these guidelines to ensure code suggestions, reviews, and contributions are robust, maintainable, and compatible with our multi-backend architecture. | ||
|
|
||
| ## 1. Decorator and API Usage | ||
|
|
||
| - The main decorator is `@cachier`. It supports parameters such as `stale_after`, `backend`, `mongetter`, `cache_dir`, `pickle_reload`, `separate_files`, `wait_for_calc_timeout`, `allow_none`, and `hash_func`. | ||
| - Arguments to cached functions must be hashable; for unhashable arguments, provide a custom hash function via the `hash_func` parameter. | ||
| - The default backend is pickle-based, storing cache files in `~/.cachier/` unless otherwise specified. MongoDB and memory backends are also supported. | ||
| - Cachier is thread-safe and supports per-function cache clearing via the `clear_cache()` method on decorated functions. | ||
| - Global configuration is possible via `set_default_params` and `enable_caching`/`disable_caching` functions. | ||
| - When reviewing code, ensure new features or bugfixes maintain compatibility with Python 3.9+, preserve thread safety, and follow the numpy docstring conventions for documentation. | ||
| - Tests are located in the `tests/` directory and should be run with `pytest`. MongoDB-related tests require either a mocked or live MongoDB instance. | ||
| - When discussing or generating code, prefer concise, readable, and well-documented Python code, and follow the established conventions in the codebase and README. | ||
| - Global configuration is possible via `set_default_params`, `set_global_params`, and `enable_caching`/`disable_caching`. | ||
|
|
||
| ## 2. Optional Dependencies and Backends | ||
|
|
||
| - Cachier supports multiple backends: `pickle`, `memory`, `mongo`, and `sql`. | ||
| - Not all dependencies are required for all backends. Code and tests for optional backends (e.g., MongoDB, SQL/SQLAlchemy) **must gracefully handle missing dependencies** and should not break import or test collection for other backends. | ||
| - Only raise errors or warnings for missing dependencies when the relevant backend is actually used (not at import time). | ||
|
|
||
| ## 3. Testing Matrix and Markers | ||
|
|
||
| - Tests are located in the `tests/` directory and should be run with `pytest`. | ||
| - Tests are marked with `@pytest.mark.<backend>` (e.g., `@pytest.mark.sql`, `@pytest.mark.mongo`, `@pytest.mark.local`). | ||
| - The CI matrix runs different backends on different OSes. Do **not** assume all tests run on all platforms. | ||
| - MongoDB-related tests require either a mocked or live MongoDB instance. | ||
| - When adding new backends that require external services (e.g., databases), update the CI matrix and use Dockerized services as in the current MongoDB and PostgreSQL setup. Exclude backends from OSes where they are not supported. | ||
|
|
||
| ## 4. Coverage, Linting, and Typing | ||
|
|
||
| - Code must pass `mypy`, `ruff`, and `pytest`. | ||
| - Use per-file or per-line ignores for known, justified issues (e.g., SQLAlchemy model base class typing, intentional use of `pickle`). | ||
| - All new code must include full type annotations and docstrings matching the style of the existing codebase. | ||
| - All docstrings should follow numpy docstring conventions. | ||
|
|
||
| ## 5. Error Handling and Warnings | ||
|
|
||
| - Do **not** emit warnings at import time for missing optional dependencies. Only raise errors or warnings when the relevant backend is actually used. | ||
|
|
||
| ## 6. Backward Compatibility | ||
|
|
||
| - Maintain backward compatibility for public APIs unless a breaking change is explicitly approved. | ||
| - Cachier supports Python 3.9+. | ||
|
|
||
| ## 7. Documentation and Examples | ||
|
|
||
| - When adding a new backend or feature, provide: | ||
| - Example usage in the README | ||
| - At least one test for each public method | ||
| - Documentation of any new configuration options | ||
| - For documentation, follow numpy docstring conventions and validate changes to `README.rst` with `python setup.py checkdocs`. | ||
|
|
||
| ## 8. General Style | ||
|
|
||
| - Prefer concise, readable, and well-documented Python code. | ||
| - Follow the existing code style and conventions for imports, docstrings, and type annotations. | ||
| - Prefer explicit, readable code over cleverness. | ||
|
|
||
| ______________________________________________________________________ | ||
|
|
||
| Thank you for contributing to Cachier! These guidelines help ensure a robust, maintainable, and user-friendly package for everyone. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.