marimo icon indicating copy to clipboard operation
marimo copied to clipboard

show edges for mo.state getters and setters in the dependency graph

Open alefminus opened this issue 9 months ago • 4 comments

Describe the bug

  1. create state
  2. 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)
  3. invoke function

Expected: function call cell evaluated triggering all getter dependent cells

Actual: Endless loop where it seems the function call cell triggers re-evaluation of itself via the function definition cell being updated?

Environment

{
  "marimo": "0.6.0",
  "OS": "Linux",
  "OS Version": "6.8.7-300.fc40.x86_64",
  "Processor": "",
  "Python Version": "3.12.3",
  "Binaries": {
    "Browser": "--",
    "Node": "v20.12.2"
  },
  "Requirements": {
    "click": "8.1.7",
    "importlib-resources": "missing",
    "jedi": "0.19.1",
    "markdown": "3.6",
    "pymdown-extensions": "10.8.1",
    "pygments": "2.18.0",
    "tomlkit": "0.12.5",
    "uvicorn": "0.29.0",
    "starlette": "0.37.2",
    "websocket": "missing",
    "typing-extensions": "missing",
    "black": "24.4.2"
  }
}

Code to reproduce

import marimo

__generated_with = "0.6.0"
app = marimo.App()


@app.cell
def __():
    import marimo as mo
    return mo,


@app.cell
def __(mo):
    get, set = mo.state(0)
    return get, set


@app.cell
def __(get, set):
    def callboth_to_advance():
        x = get()
        set(x + 1)
    return callboth_to_advance,


@app.cell
def __(callboth_to_advance):
    callboth_to_advance()
    return


@app.cell
def __(get):
    get()
    return


if __name__ == "__main__":
    app.run()

alefminus avatar May 22 '24 05:05 alefminus