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?