My name is Abhi and I have recently joined Streamlit as a Product Manager. One of my first projects at Streamlit is to start working on Programmable State. Previously, Thiago has also posted about Programmable State here: Programmable State for Streamlit and the community feedback has been super helpful!
We have started scoping the work and building prototypes. We are looking to interview users as well as sign up users for a closed beta program for Programmable State. (More in the survey)
Can you please spare 5-10mins to give us your inputs on Programmable State? - https://forms.gle/inH4iM322KJiw8Xh8 (Please leave a reply on the thread or add an emoji when you are done )
Just throwing this in here for inspiration: I recently started working on an analytics extension for streamlit (code, very much WIP at this stage), where I use programmable state to track when users change their input to a widget. So far, I’m using @thiago’s session state implementation to store a dict with all widget states (and update this whenever a user interacts with a widget).
In discussions with @abhi and @kmcgrady the following example was thought of, spring boarding off of an example built by @kmcgrady:
A key design decision is that the state objects can be passed to streamlit widgets. And then by “linking” state objects together, this can cause Streamlit widgets to update each other upon user interaction. These links are undergone by calling the method link_to on the state object to be linked from, and passing it two arguments, the first the state object to link to, and second a conversion function converting the value of one state object to the second:
Importantly those conversion functions should be pure functions, with no side effects. They’re not designed to be used as callbacks, instead just converting the state objects and they should be able to be cached, for the same input, always producing the same output without any side-effects. If subsequent control flow is desired, the standard Streamlit approach can be utilised for tests based on those updated values:
And also, you are free to use standard Streamlit flow to have scenarios where you then update these state objects, this would result in the app to update (rerun) as normal, as well as the linked widgets:
It does mean that to access the actual value of the state object you need to call something like the following:
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.