Skip to content
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

fix: handle shadowed variables in mo.cache, update tutorials #2480

Merged
merged 11 commits into from
Oct 3, 2024

Conversation

akshayka
Copy link
Contributor

@akshayka akshayka commented Oct 2, 2024

This PR updates tutorials to use mo.cache, and fixes mo.cache to handle shadowed variables.

Copy link

vercel bot commented Oct 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 3, 2024 6:03pm
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 3, 2024 6:03pm

@dmadisetti
Copy link
Collaborator

Is this on the cache hit?

Comment on lines 117 to 119
# In case scope shadoes variables
for arg in self._args:
self.scope.pop(arg, None)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah this is what I was looking for

import functools


@functools.cache
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can check with _plots.cache_info().hits, and as was, there would never be a cache hit with functools, since the function would get redefined and clear the cache

I did find that for, mo.cache, private functions did not have a persistent cache- but solved that

@akshayka akshayka changed the title Update tutorials to use mo.cache fix: handle shadowed variables in mo.cache, update tutorials Oct 3, 2024
@akshayka akshayka merged commit c5354cf into main Oct 3, 2024
33 checks passed
@akshayka akshayka deleted the aka/cache-in-tutorials branch October 3, 2024 18:12
Copy link

github-actions bot commented Oct 3, 2024

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.8.23-dev26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants