-
-
Notifications
You must be signed in to change notification settings - Fork 364
chore/doctests #3500
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
chore/doctests #3500
Changes from 53 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
abb764e
Add _cache.py first attempt
ruaridhg d72078f
test.py ran without error, creating test.zarr/
ruaridhg e1266b4
Added testing for cache.py LRUStoreCache for v3
ruaridhg 40e6f46
Fix ruff errors
ruaridhg eadc7bb
Add working example comparing LocalStore to LRUStoreCache
ruaridhg 5f90a71
Delete test.py to clean-up
ruaridhg ae51d23
Added lrustorecache to changes and user-guide docs
ruaridhg e58329a
Fix linting issues
ruaridhg 26bd3fc
Implement dual store cache
ruaridhg 5c92d48
Fixed failing tests
ruaridhg f0c302c
Fix linting errors
ruaridhg 11f17d6
Add logger info
ruaridhg a7810dc
Delete unnecessary extra functionality
ruaridhg a607ce0
Rename to caching_store
ruaridhg 8e79e3e
Add test_storage.py
ruaridhg d31e565
Fix logic in _caching_store.py
ruaridhg 92cd63c
Update tests to match caching_store implemtation
ruaridhg aa38def
Delete LRUStoreCache files
ruaridhg 86dda09
Update __init__
ruaridhg bb807d0
Add functionality for max_size
ruaridhg ed4b284
Add tests for cache_info and clear_cache
ruaridhg 0fe580b
Delete test.py
ruaridhg 1d9a1f7
Fix linting errors
ruaridhg 16ae3bd
Update feature description
ruaridhg 62b739f
Fix errors
ruaridhg f51fdb8
Fix cachingstore.rst errors
ruaridhg ffa9822
Fix cachingstore.rst errors
ruaridhg cda4767
Merge branch 'main' into rmg/cache_remote_stores_locally
ruaridhg d20843a
Fixed eviction key logic with proper size tracking
ruaridhg 4b8d0a6
Increase code coverage to 98%
ruaridhg 84a87e2
Fix linting errors
ruaridhg f3b6b3e
Merge branch 'main' into rmg/cache_remote_stores_locally
d-v-b 114a29a
Merge branch 'main' into rmg/cache_remote_stores_locally
d-v-b 39cb6b1
Merge branch 'main' into rmg/cache_remote_stores_locally
d-v-b 1f200ed
Merge branch 'main' of https://github.com/zarr-developers/zarr-python…
d-v-b f9c8c09
move cache store to experimental, fix bugs
d-v-b 6861490
update changelog
d-v-b 41d182c
remove logging config override, remove dead code, adjust evict_key lo…
d-v-b 83539d3
add docs
d-v-b 56db161
add tests for relaxed cache coherency
d-v-b 3d21514
adjust code examples (but we don't know if they work, because we don'…
d-v-b 1202fb1
update ci; don't save temporary files for cachestore; add doctest env
d-v-b 4dd7565
add doctests
d-v-b b0a8c63
Merge branch 'main' of github.com:zarr-developers/zarr-python into ch…
d-v-b b2be131
remove test_cache_store
d-v-b e810306
update ci
d-v-b d755b2a
update ci
d-v-b f34446e
update ci, finally
d-v-b 9721336
Merge branch 'main' into chore/doctests
d-v-b f02b539
remove unnecessary doctest script
d-v-b be33a9a
Merge branch 'chore/doctests' of github.com:d-v-b/zarr-python into ch…
d-v-b 7e7bf6c
restore s3 tests
d-v-b 4b0bca2
add s3fs dep
d-v-b 6faa44a
Merge branch 'main' into chore/doctests
d-v-b e38c508
test code examples in src
d-v-b 2c192d4
fix broken code examples
d-v-b ef6303e
remove ectopic changelog
d-v-b 584acdd
make docstring code examples executible, and fix errors
d-v-b a897230
update async docstrings
d-v-b 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
Some comments aren't visible on the classic Files Changed page.
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Adds `zarr.experimental.cache_store.CacheStore`, a `Store` that implements caching by combining two other `Store` instances. See the [docs page](https://zarr.readthedocs.io/en/latest/user-guide/cache-store) for more information about this feature. | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
""" | ||
Tests for executable code blocks in markdown documentation. | ||
|
||
This module uses pytest-examples to validate that all Python code examples | ||
with exec="true" in the documentation execute successfully. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from collections import defaultdict | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
pytest_examples = pytest.importorskip("pytest_examples") | ||
|
||
# Find all markdown files with executable code blocks | ||
docs_root = Path(__file__).parent.parent / "docs" | ||
|
||
|
||
def find_markdown_files_with_exec() -> list[Path]: | ||
"""Find all markdown files containing exec="true" code blocks.""" | ||
markdown_files = [] | ||
|
||
for md_file in docs_root.rglob("*.md"): | ||
try: | ||
content = md_file.read_text(encoding="utf-8") | ||
if 'exec="true"' in content: | ||
markdown_files.append(md_file) | ||
except Exception: | ||
# Skip files that can't be read | ||
continue | ||
|
||
return sorted(markdown_files) | ||
|
||
|
||
def group_examples_by_session() -> list[tuple[str, str]]: | ||
""" | ||
Group examples by their session and file, maintaining order. | ||
|
||
Returns a list of session_key tuples where session_key is | ||
(file_path, session_name). | ||
""" | ||
all_examples = list(pytest_examples.find_examples(docs_root)) | ||
|
||
# Group by file and session | ||
sessions = defaultdict(list) | ||
|
||
for example in all_examples: | ||
settings = example.prefix_settings() | ||
if settings.get("exec") != "true": | ||
continue | ||
|
||
# Use file path and session name as key | ||
file_path = example.path | ||
session_name = settings.get("session", "_default") | ||
session_key = (str(file_path), session_name) | ||
|
||
sessions[session_key].append(example) | ||
|
||
# Return sorted list of session keys for consistent test ordering | ||
return sorted(sessions.keys(), key=lambda x: (x[0], x[1])) | ||
|
||
|
||
def name_example(path: str, session: str) -> str: | ||
"""Generate a readable name for a test case from file path and session.""" | ||
return f"{Path(path).relative_to(docs_root)}:{session}" | ||
|
||
|
||
# Get all example sessions | ||
@pytest.mark.parametrize( | ||
"session_key", group_examples_by_session(), ids=lambda v: name_example(v[0], v[1]) | ||
) | ||
def test_documentation_examples( | ||
session_key: tuple[str, str], | ||
eval_example: pytest_examples.EvalExample, # type: ignore[name-defined] | ||
) -> None: | ||
""" | ||
Test that all exec="true" code examples in documentation execute successfully. | ||
|
||
This test groups examples by session (file + session name) and runs them | ||
sequentially in the same execution context, allowing code to build on | ||
previous examples. | ||
|
||
This test uses pytest-examples to: | ||
- Find all code examples with exec="true" in markdown files | ||
- Group them by session | ||
- Execute them in order within the same context | ||
- Verify no exceptions are raised | ||
""" | ||
file_path, session_name = session_key | ||
|
||
# Get examples for this session | ||
all_examples = list(pytest_examples.find_examples(docs_root)) | ||
examples = [] | ||
for example in all_examples: | ||
settings = example.prefix_settings() | ||
if settings.get("exec") != "true": | ||
continue | ||
if str(example.path) == file_path and settings.get("session", "_default") == session_name: | ||
examples.append(example) | ||
|
||
# Run all examples in this session sequentially, preserving state | ||
module_globals: dict[str, object] = {} | ||
for example in examples: | ||
result = eval_example.run(example, module_globals=module_globals) | ||
# Update globals with the results from this execution | ||
module_globals.update(result) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@d-v-b can you please remove this addition? It is already properly documented using the PR number in https://github.com/zarr-developers/zarr-python/blob/main/changes/3366.feature.md