fix: decorator invalidation for caching#8171
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
mscolnick
previously approved these changes
Feb 7, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates marimo’s caching/hash computation so that changes to decorator expressions (including decorator-factory arguments and referenced variables) properly invalidate caches, addressing cases where ast.FunctionDef.body omits decorator information.
Changes:
- Introduce
get_hashable_ast()to include decorator AST (as synthetic statements) when building hashable modules, with support for skipping cache decorators and any outer decorators. - Switch cache/base block hashing and
hash_function()to useget_hashable_ast()instead ofstrip_function(). - Add unit and E2E tests covering decorator-parameter hashing and decorator ref tracking.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
marimo/_ast/transformers.py |
Adds get_hashable_ast() and decorator handling to ensure decorator changes participate in hashing. |
marimo/_save/save.py |
Uses get_hashable_ast(..., skip_decorators={...}) for cached function base-block hashing. |
marimo/_save/hash.py |
Updates hash_function() to hash via get_hashable_ast() rather than the removed helper. |
tests/_ast/test_transformers.py |
Renames/updates transformer tests and adds coverage for decorator inclusion/skipping. |
tests/_save/test_hash.py |
Adds regression/E2E tests to confirm decorator param/ref changes affect cache hashes as intended. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
mscolnick
approved these changes
Feb 9, 2026
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
Closes #8155
ast.Function.bodydoes not include parent decorator information. As such hashing theastproduced invalid cache hits when inner decorators changed. As a work around, we artificially append the decorator statements into the function body for module hashing. Additionally, to prevent cache invalidations between:and
we scan the decorators and remove all prior (and including) the caching wrap.