-
Notifications
You must be signed in to change notification settings - Fork 0
Ci/update zarr 3.0.9 #78
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
43c6dc7
fix: ensure read_only is properly set on shallow copy
Faolain 6d48c19
fix: remaining guards
Faolain b0ede54
fix: update tests from using master-latest to 0.36.0
Faolain 850cee8
fix: align read_only variables
Faolain 7094b5f
test: add extra test for roundtrip on ro and rw changes
Faolain 6171905
Allow KuboCAS to reopen after being closed
0xSwego 0f56989
test: cover closed external clients
0xSwego 8086d50
Merge pull request #81 from dClimate/codex/fix-runtimeerror-with-kubo…
Faolain 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # tests/test_read_only_guards.py | ||
| import numpy as np | ||
| import pytest | ||
| from Crypto.Random import get_random_bytes | ||
|
|
||
| from py_hamt import HAMT, InMemoryCAS, SimpleEncryptedZarrHAMTStore, ZarrHAMTStore | ||
|
|
||
|
|
||
| # ---------- helpers ---------------------------------------------------- | ||
| async def _rw_plain(): | ||
| cas = InMemoryCAS() | ||
| hamt = await HAMT.build(cas=cas, values_are_bytes=True) | ||
| return ZarrHAMTStore(hamt, read_only=False) | ||
|
|
||
|
|
||
| async def _rw_enc(): | ||
| cas = InMemoryCAS() | ||
| hamt = await HAMT.build(cas=cas, values_are_bytes=True) | ||
| key, hdr = get_random_bytes(32), b"hdr" | ||
| return SimpleEncryptedZarrHAMTStore(hamt, False, key, hdr) | ||
|
|
||
|
|
||
| # ---------- plain store ------------------------------------------------ | ||
| @pytest.mark.asyncio | ||
| async def test_plain_read_only_guards(): | ||
| rw = await _rw_plain() | ||
| ro = rw.with_read_only(True) | ||
|
|
||
| assert ro.read_only is True | ||
| with pytest.raises(Exception): | ||
| await ro.set("k", np.array([1], dtype="u1")) | ||
| with pytest.raises(Exception): | ||
| await ro.delete("k") | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_plain_with_same_flag_returns_self(): | ||
| rw = await _rw_plain() | ||
| assert rw.with_read_only(False) is rw # early‑return path | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_roundtrip_plain_store(): | ||
| rw = await _rw_plain() # writable store | ||
| ro = rw.with_read_only(True) # clone → RO | ||
| assert ro.read_only is True | ||
| assert ro.hamt is rw.hamt | ||
|
|
||
| # idempotent: RO→RO returns same object | ||
| assert ro.with_read_only(True) is ro | ||
|
|
||
| # back to RW (new wrapper) | ||
| rw2 = ro.with_read_only(False) | ||
| assert rw2.read_only is False and rw2 is not ro | ||
| assert rw2.hamt is rw.hamt | ||
|
|
||
| # guard: cannot write through RO wrapper | ||
| with pytest.raises(Exception): | ||
| await ro.set("k", np.array([0], dtype="u1")) | ||
|
|
||
|
|
||
| # ---------- encrypted store ------------------------------------------- | ||
| @pytest.mark.asyncio | ||
| async def test_encrypted_read_only_guards_and_self(): | ||
| rw = await _rw_enc() | ||
| assert rw.with_read_only(False) is rw # same‑flag path | ||
| ro = rw.with_read_only(True) | ||
| with pytest.raises(Exception): | ||
| await ro.set("k", np.array([2], dtype="u1")) | ||
| with pytest.raises(Exception): | ||
| await ro.delete("k") |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
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.
Missing
read_onlyproperty to use_forced_read_onlyattributeThe
with_read_onlymethod sets_forced_read_onlyon line 122, but the class doesn't have aread_onlyproperty that checks this attribute. Without such a property, the cloned instance won't actually respect the forced read-only state.Add a
read_onlyproperty similar to the one inZarrHAMTStore:This property should be added before the
with_read_onlymethod to ensure the forced read-only state is properly respected throughout the class.🧰 Tools
🪛 GitHub Actions: Triggered on push from Faolain to branch/tag ci/update-zarr-3.0.9
[error] 115-115: Coverage missing at line 115. Coverage is below the required 100% threshold.
🤖 Prompt for AI Agents
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.
i don't think this understands that the encryption class is built from the ZarrHAMTStore so we should be able to safely ignore this as the ZarrHAMTStore does have this
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.
@TheGreatAlgo You're absolutely correct! I apologize for the oversight. Since
SimpleEncryptedZarrHAMTStoreinherits fromZarrHAMTStore, it automatically inherits theread_onlyproperty that was added to the parent class.Looking at the inheritance relationship:
The parent
ZarrHAMTStoreclass already has theread_onlyproperty that returns_forced_read_onlyif set, otherwise falls back toself.hamt.read_only. This means thewith_read_onlymethod will work correctly as the cloned instance will respect the_forced_read_onlyattribute through the inherited property.The comment can be safely ignored as the implementation is correct through inheritance.
🐰✨
/| /|
( ✌️ )
|(_)|
^ ^
✏️ Learnings added
🧠 Learnings used
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.
damn right it will work
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.
@TheGreatAlgo Exactly! The inheritance chain makes it all work seamlessly. Thanks for keeping me on track with the codebase architecture! 🎯
🧠 Learnings used