ECMWFCode4Earth / atmospheric-explorer

repository for 2023 Code for Earth project to develop a tool for exploration of CAMS atmospheric composition datasets
Apache License 2.0
4 stars 0 forks source link

Session state for Streamlit app #18

Open luigibrancati opened 1 year ago

luigibrancati commented 1 year ago

As mentioned in this PR #15, in each page we initialize the session state variables relevant to the page, e.g. on module Anomalies Plot.py we do

if "eac4_anomalies_start_date" not in st.session_state:
    st.session_state["eac4_anomalies_start_date"] = datetime(2022, 1, 1)
if "eac4_anomalies_end_date" not in st.session_state:
    st.session_state["eac4_anomalies_end_date"] = datetime(2022, 12, 31)
if "eac4_anomalies_times" not in st.session_state:
    st.session_state["eac4_anomalies_times"] = ["00:00"]

Is there a better way? Maybe initialize all used vars in session state at the beginning of the program? Or using a config file?