fix: async cache_clear() TypeError + nested numpy serialization#54
Merged
fix: async cache_clear() TypeError + nested numpy serialization#54
Conversation
cache_clear() called ainvalidate_cache() without awaiting, silently discarding the coroutine. The cache was never actually cleared. Now raises TypeError directing users to await fn.ainvalidate_cache(). Closes #49
_auto_default() had no handler for ndarray, so msgpack.packb() raised TypeError when traversing container types with nested numpy arrays. Added __ndarray__ marker to _auto_default/_auto_object_hook for roundtrip serialization of nested arrays via the msgpack fallback path. Closes #50
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Combined fix for two related serialization/decorator bugs.
Fix 1:
cache_clear()broken for async functions (#49)cache_clear()calledainvalidate_cache()without awaiting, silently discarding the coroutine — cache was never cleared. Now raisesTypeErrordirecting users toawait fn.ainvalidate_cache().Root cause:
wrapper.py:1395— sync function cannot await a coroutine.Fix 2:
serializer="auto"fails on nested numpy arrays (#50)_auto_default()had no handler for ndarray, somsgpack.packb()raisedTypeErrorwhen numpy arrays were nested inside dicts or lists (despite documentation claiming support). Added__ndarray__marker to_auto_default()and_auto_object_hook()for roundtrip serialization.Root cause: Top-level numpy detection only; msgpack fallback path had no numpy handler.
Test plan
Issue #49 (4 tests)
test_cache_clear_raises_type_error_for_async_functiontest_cache_clear_error_message_suggests_ainvalidatetest_cache_clear_does_not_raise_for_sync_function(regression guard)test_async_ainvalidate_cache_still_worksIssue #50 (19 tests)
__ndarray__markersCloses #49
Closes #50