-
Notifications
You must be signed in to change notification settings - Fork 760
tests: cache invaliadation for external decorators #5758
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
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
mscolnick
previously approved these changes
Jul 26, 2025
akshayka
approved these changes
Jul 28, 2025
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.14.14-dev35 |
dmadisetti
added a commit
that referenced
this pull request
Jul 30, 2025
This reverts commit 236f8cd.
dmadisetti
added a commit
that referenced
this pull request
Jul 30, 2025
dmadisetti
added a commit
that referenced
this pull request
Aug 1, 2025
## 📝 Summary Bug initially mistaken to be caused from #5758 (happened to be observed around the same time as that push) Cache wrapping previously assumed that a context would be present with all import and definitions defined. Module lookup logic became stale after #5678 This PR fixes this issue and provides specific decorator tests. Fixes internal demo, and previously observed behavior.
dmadisetti
added a commit
that referenced
this pull request
Aug 1, 2025
This was referenced Aug 1, 2025
dmadisetti
added a commit
that referenced
this pull request
Aug 6, 2025
## 📝 Summary Follow up to #5758 Solves reference dependency issues in an external lib, by creating a partial graph of toplevel functions on invocation. Previously, the "graph" of an external function was allowed to be blank. This is incorrect, since both setup cell values, and other top level definitions can be exposed to the cached function. For example in tests/_save/external_decorators/transitive_wrappers_1.py ```python with app.setup: ... impure_state = ... @app.function def my_impure_decorator(func): """An impure decorator that depends on impure_state""" @functools.wraps(func) def wrapper(*args: Any, **kwargs: Any): # Decorator depends on impure_state wrapper._value = ... # dependent on impure state ... return func(*args, **kwargs) return wrapper ... @app.function @my_impure_decorator def pure_function(): # This function itself is pure (no external dependencies) return 42 ... ``` on `from external_decorators.transitive_wrappers_1 import pure_function` a partial graph is constructed to invalidate pure_function based on its relationship `pure_function` -> `impure_function` -> `impure_state`. Whereas before, we just ignored these relationships because `pure_function` was determined to be an external function and thus 'pure'.
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
External functions are assumed to be pure. If an external function wraps a notebook function, then our test was unable to pick up the notebook change. This PR adds test to catch this behavior, and adds an appropriate fix (explicitly checking to see if the external function is used as a wrapper)
The PR also catches the general case of pickle not correctly capturing the transitive references of unhashable ContextExecution objects. This is a detectable edgecase with poorly defined behavior (by virtue of pickle). Future work should include adding a lint rule encouraging users away from this condition.