Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

st.server_state with endpoint access (like st.session_state, but for global values; different from pickled user sessions) #10067

Open
2 tasks done
sfc-gh-dmatthews opened this issue Dec 22, 2024 · 1 comment
Labels
feature:state type:enhancement Requests for feature enhancements or new features

Comments

@sfc-gh-dmatthews
Copy link
Collaborator

sfc-gh-dmatthews commented Dec 22, 2024

Checklist

  • I have searched the existing issues for similar feature requests.
  • I added a descriptive title and summary to this issue.

Summary

Currently, we can use st.cache_data and st.cache_resource to "save" values that can be accessed between sessions. What if there was an API similar to st.session_state that was shared between sessions? I suggest st.server_state.

Additionally, a Streamlit app could include an endpoint for accessing and updating server state.

Why?

A common pattern is for a Streamlit app to reach out and collect data from a remote location, typically saving it with st.cache_data. If there was some server state combined with an endpoint, a remote source could be able to ping the app and initiate an update of data. This prevents needing to schedule an app to run to update data or making a random user wait if they are the first to connect beyond a cached values TTL.

This would also be useful for IoT use cases where a smart device can send an alert to the app.

Another feature request to send a global message to all sessions (#7312) could also be accommodated with this.

How?

Add a new API st.server_state which is global with all sessions having read/write access.
Add an (authenticated) enpoint for remote sources to connect to and update values in st.server_state.

Additional Context

This is related to requests for app state (#8609), but I'm suggesting something narrower.

@sfc-gh-dmatthews sfc-gh-dmatthews added the type:enhancement Requests for feature enhancements or new features label Dec 22, 2024
Copy link

To help Streamlit prioritize this feature, react with a 👍 (thumbs up emoji) to the initial post.

Your vote helps us identify which enhancements matter most to our users.

Visits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:state type:enhancement Requests for feature enhancements or new features
Projects
None yet
Development

No branches or pull requests

2 participants