You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In example below, if you use set to set the value of a particular query param, other cells that access the value of a different query param seem to re-run. This is just a toy example, but in my case this behavior leads to a number of things that will not change at all being re-rendered.
In the example below just push the button and the cell with the sleep(10) that is displaying unrelated text will rerun presumably because query params changed but none of the specific params accessed by this cell have actually changed.
Environment
Using marimo 0.4.0
Code to reproduce
import marimo as mo
from random import randint
import time
params = mo.query_params()
time.sleep(10)
text = mo.ui.text(
label="Enter something to display 🎉",
value=params["text"] or "",
full_width=True,
)
text
mo.md(text.value)
button = mo.ui.button(label="Click me to generate a new number")
button
button
my_number = params["number"] or randint(0, 1000)
params.set("number", my_number)
mo.md(f"Your number is {my_number}")
The text was updated successfully, but these errors were encountered:
This makes sense in the queryparams' current form. We can add a concept of lens to be able to scope down the scope of the reactiveness: e.g get_text, set_text = query_params.lens("text") which gives you a more granular piece of state.
(you might be able to do this today with mo.state() as well)
Yeah totally, is clear in the docs that this is should currently work (sorry bug probably the wrong label here!). Something like that would definitely be helpful at least in my case. I can take a closer look at mo.state and see if I could make something work with that, my quick initial attempts after looking at the docs weren't successful but also my first time looking at it. Was trying to use getter, setter = mo.state(mo.query_params()) and then interacting with it that way, which may not make sense.
Describe the bug
In example below, if you use set to set the value of a particular query param, other cells that access the value of a different query param seem to re-run. This is just a toy example, but in my case this behavior leads to a number of things that will not change at all being re-rendered.
In the example below just push the button and the cell with the sleep(10) that is displaying unrelated text will rerun presumably because query params changed but none of the specific params accessed by this cell have actually changed.
Environment
Using marimo 0.4.0
Code to reproduce
The text was updated successfully, but these errors were encountered: