Skip to content

Commit

Permalink
Added warning prior to download of invalid config.
Browse files Browse the repository at this point in the history
  • Loading branch information
pineapple-cat committed Mar 26, 2024
1 parent 7d12645 commit 45894dd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion post-processing/streamlit_post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def update_ui(post: PostProcessing, config: ConfigHandler, e: 'Exception | None'
if config.title:
st.download_button("Download Config", config.to_yaml(),
"{0}_config.yaml".format((config.title).lower().replace(" ", "_")),
use_container_width=True)
on_click=validate_download_config, use_container_width=True)
else:
st.button("Download Config", disabled=True, use_container_width=True)

Expand Down Expand Up @@ -407,6 +407,20 @@ def rerun_post_processing():
post.plot = None


def validate_download_config():
"""
Warn the user if the current session state config is invalid before download.
"""

state = st.session_state
try:
# validate config
read_config(state.config.to_dict())
except Exception as e:
st.warning("Download successful.\n\n" + type(e).__name__ + ": " + str(e))
state.post.plot = None


def read_args():
"""
Return parsed command line arguments.
Expand Down

0 comments on commit 45894dd

Please sign in to comment.