Coder Social home page Coder Social logo

Comments (4)

alefminus avatar alefminus commented on September 20, 2024

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.

akshayka avatar akshayka commented on September 20, 2024

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.

alefminus avatar alefminus commented on September 20, 2024

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.

akshayka avatar akshayka commented on September 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.