-
Notifications
You must be signed in to change notification settings - Fork 761
fix: improved robustness of cache wrapper in module contexts #5873
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
marimo/_save/toplevel.py
Outdated
| LOGGER = _loggers.marimo_logger() | ||
|
|
||
|
|
||
| def graph_from_app(fn: Callable[..., Any], app: App) -> DirectedGraph: |
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 wouldn't mind a bit of a sanity check here.
This is the setup:
- we are loading a marimo notebook as a module
- a toplevel cache decorated function has dependencies on other top level dependencies.
This function is called on first invocation, where we do a best effort to create the graph thus far with top level definitions.
Notably, function definitions can be out of order (solved by waiting for invocation), but also invoked even before the app is done being constructed (via decorators). We grab app from the scope of the function declaration, and construct our own version of the graph with only top level deps.
485580a to
e57df97
Compare
|
Woops. Saw the fastforward requested everyone. Sorry about that. rebasing |
a6c247e to
3d617b2
Compare
528d0d2 to
15cb87c
Compare
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.14.17-dev38 |
📝 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
on
from external_decorators.transitive_wrappers_1 import pure_functiona partial graph is constructed to invalidate pure_function based on its relationshippure_function->impure_function->impure_state. Whereas before, we just ignored these relationships becausepure_functionwas determined to be an external function and thus 'pure'.