I have this function that read configuration files and would like to just run once. but it seems like I can’t access it again even if I store it as a session state.
Import streamlit as st
Import configparser
config_file = “config.ini”
@st.cache(hash_funcs = {configparser.ConfigParser: lambda _: None})
def read_config_files():
config = configparser.ConfigParser()
config.read(config_file)
if ‘config’ not in st.session_state:
st.session_state.config = config
def load_page():
st.title(st.session_state.config[st][page_title])
if __name__ == “__main__”:
load_page()
There is this error stating st.session_state has no key config. Did you forget to initialize? How do I go about running a particular function just once and of storing objects?