Comments (4)
Importantly the case of a single cell containing getter and setter does work (does not cause an infinite loop, only evaluates once when caused to evaluate), so is there some special handling for it? perhaps it can be elaborated to cover this? or maybe a complete check for loops should be done (i.e. walking the graph) and avoided? Special edges in the dependency graph also could help, showing the Cell_containing_setter_call -> Cell_containing_getter_call connection?
from marimo.
call getter and setter from same function (found it while trying to implement a log for serial connection date, example shows an example of a counter)
For such cases, pass a function to set_state
instead of calling get_state
to avoid re-queuing the cell for execution: set_state(lambda v: v + 1)
.
so is there some special handling for it?
There is some special handling, described in this section:
https://docs.marimo.io/guides/state.html#updating-state
We don't do much any runtime analysis of the graph (it opens up a can of worms that is difficult to reason about). We might be able to add a debugging feature that highlights "state" edges in the dependency viewer.
My preference is to leave as is -- I know it's confusing but I don't see any clean solutions -- and instead encourage people to pass functions to set_state
.
from marimo.
Alright, I thought working on the additional edges in the dependency sidebar would be cool, so if you change your mind about it let me know :) Closing for now.
from marimo.
Alright, I thought working on the additional edges in the dependency sidebar would be cool, so if you change your mind about it let me know :) Closing for now.
Oh, yes that would be cool! I suppose it could even be done with some careful static analysis.
I was mostly expressing hesitation of detecting cycles at runtime, or further modifying the rules of how state updates are propagated. But if you have ideas I'm open to hearing them
from marimo.
Related Issues (20)
- Something went wrong NetworkError when attempting to fetch - NetworkError when attempting to fetch resource. HOT 1
- Column-specific filtering includes null values HOT 2
- Refreshing a new notebook spawns multiple sessions
- Customizing the actions links in the Altair charts HOT 1
- Copying a notebook in a subdirectory leads to a "No such file or directory error". HOT 2
- Markdown cells, code cells, and smart cells: taking inspiration from Livebook HOT 16
- Table column summaries break when column name has a `.`
- [CI] BE only changes don't trigger required FE tests HOT 3
- Make generated Python files `mypy` error-free HOT 6
- mo.ui.number rendered wrongly (.value != displayed one) HOT 2
- Memory leak HOT 1
- px.scatter_map does not display HOT 1
- ConnectionResetError when using Pymc HOT 5
- `marimo run` should have an option to stop once the notebook has finished running HOT 3
- sidebar order of cells not deterministic HOT 2
- Hash source code to check whether exported HTML is up-to-date HOT 5
- Multiple for loops with the same iterator causes error HOT 3
- No new line when copying from Marimo NB output HOT 5
- Change `freeze_column_left` in-place won't update freezing HOT 1
- Sorting a table with mixed values and ui elements leads to ui elements not rendered HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marimo.