
Security News
pnpm 10.12 Introduces Global Virtual Store and Expanded Version Catalogs
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
streamlit-meta-state
Advanced tools
StreamlitMetaState is a Python package that enables seamless session persistence for class instances in Streamlit applications. By leveraging a metaclass and descriptors, it automatically binds class attributes to Streamlit's session state, eliminating the need for manual session management.
StreamlitMetaState
as a metaclass.Install StreamlitMetaState via pip:
pip install streamlit-meta-state
To ensure proper functionality, class variables must be annotated in the class definition.
import streamlit as st
from streamlit_meta_state import MetaSessionState
class MyPersistentClass(metaclass=MetaSessionState):
name: str
counter: int
def __init__(self, name: str, counter: int):
self.name = name
self.counter = counter
# Create a persistent instance
my_instance = MyPersistentClass(name="Example", counter=10, instance_key="example_instance")
st.write(f"The counter for '{my_instance.name}' is currently {my_instance.counter}")
if st.button(label=f"Increase '{my_instance.name}'"):
my_instance.counter += 1 # Changes persist across reruns
st.rerun()
You can bind Streamlit widgets directly to class attributes using their session keys:
st.text_input(label="MyPersistentClass.name", key=f"{my_instance.__instance_key__}.name")
st.write(f"The current value on the 'MyPersistentClass.name' is '{my_instance.name}'")
SessionVar
and ensures instances are stored persistently using a unique instance_key
.This project is licensed under the MIT License.
Contributions are welcome! If you'd like to improve StreamlitMetaState, feel free to submit a pull request.
If you encounter any issues, please open an issue on GitHub.
FAQs
A Streamlit module for session state management
We found that streamlit-meta-state demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
Security News
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.