From 3dfef2f57f7b9cec61d76a075f8c595613bb46a0 Mon Sep 17 00:00:00 2001 From: Arslan Date: Wed, 13 Nov 2024 23:14:30 +0100 Subject: [PATCH 1/4] every page save params of current session/ during exec at the end --- content/documentation.py | 9 ++++++--- content/download_section.py | 8 +++++--- content/quickstart.py | 6 ++++-- content/raw_data_viewer.py | 5 ++++- content/run_example_workflow.py | 5 ++++- content/topp_workflow_execution.py | 3 ++- content/topp_workflow_file_upload.py | 3 ++- content/topp_workflow_parameter.py | 4 +++- content/topp_workflow_results.py | 3 ++- 9 files changed, 32 insertions(+), 14 deletions(-) diff --git a/content/documentation.py b/content/documentation.py index c308213b..8dc95ebb 100644 --- a/content/documentation.py +++ b/content/documentation.py @@ -1,9 +1,9 @@ import streamlit as st -from src.common.common import page_setup +from src.common.common import page_setup, save_params from pathlib import Path from docs.toppframework import content as topp_framework_content -page_setup() +params = page_setup() st.title("Documentation") @@ -106,4 +106,7 @@ if page == pages[5]: with open(Path("docs", "deployment.md"), "r", encoding="utf-8") as f: content = f.read() - st.markdown(content) \ No newline at end of file + st.markdown(content) + + +save_params(params) diff --git a/content/download_section.py b/content/download_section.py index 8856a7b3..0ce00738 100644 --- a/content/download_section.py +++ b/content/download_section.py @@ -3,10 +3,10 @@ from pathlib import Path import shutil -from src.common.common import page_setup +from src.common.common import page_setup, save_params from zipfile import ZipFile, ZIP_DEFLATED -page_setup() +params = page_setup() # Define output folder here; all subfolders will be handled as downloadable # directories @@ -71,4 +71,6 @@ with columns[2]: if st.button(f"🗑️ {directory.name}", use_container_width=True): shutil.rmtree(directory) - st.rerun() \ No newline at end of file + st.rerun() + +save_params(params) diff --git a/content/quickstart.py b/content/quickstart.py index a2a8eac8..43e3e4f7 100644 --- a/content/quickstart.py +++ b/content/quickstart.py @@ -21,9 +21,9 @@ from pathlib import Path import streamlit as st -from src.common.common import page_setup, v_space +from src.common.common import page_setup, v_space, save_params -page_setup(page="main") +params = page_setup(page="main") st.markdown("# 👋 Quick Start") st.markdown("## Template for OpenMS web apps using the **streamlit** framework") @@ -163,3 +163,5 @@ label="How to run any command line tool as subprocess from within the OpenMS web app.", icon="➡️", ) + +save_params(params) diff --git a/content/raw_data_viewer.py b/content/raw_data_viewer.py index d788e25d..a5c0415e 100755 --- a/content/raw_data_viewer.py +++ b/content/raw_data_viewer.py @@ -2,7 +2,7 @@ import streamlit as st -from src.common.common import page_setup +from src.common.common import page_setup, save_params from src import view @@ -42,3 +42,6 @@ view.view_spectrum() with tabs[2]: view.view_bpc_tic() + + +save_params(params) diff --git a/content/run_example_workflow.py b/content/run_example_workflow.py index 49e70e9c..5d827965 100755 --- a/content/run_example_workflow.py +++ b/content/run_example_workflow.py @@ -56,4 +56,7 @@ -mzmlfileworkflow.result_section(result_dir) \ No newline at end of file +mzmlfileworkflow.result_section(result_dir) + + +save_params(params) diff --git a/content/topp_workflow_execution.py b/content/topp_workflow_execution.py index 4da0f3a7..fbf852d0 100644 --- a/content/topp_workflow_execution.py +++ b/content/topp_workflow_execution.py @@ -1,5 +1,5 @@ import streamlit as st -from src.common.common import page_setup +from src.common.common import page_setup, save_params from src.Workflow import Workflow @@ -11,4 +11,5 @@ wf.show_execution_section() +save_params(params) diff --git a/content/topp_workflow_file_upload.py b/content/topp_workflow_file_upload.py index de8916a8..86c5f1f4 100644 --- a/content/topp_workflow_file_upload.py +++ b/content/topp_workflow_file_upload.py @@ -1,5 +1,5 @@ import streamlit as st -from src.common.common import page_setup +from src.common.common import page_setup, save_params from src.Workflow import Workflow @@ -11,4 +11,5 @@ wf.show_file_upload_section() +save_params(params) diff --git a/content/topp_workflow_parameter.py b/content/topp_workflow_parameter.py index cb0573d6..2e316848 100644 --- a/content/topp_workflow_parameter.py +++ b/content/topp_workflow_parameter.py @@ -1,5 +1,5 @@ import streamlit as st -from src.common.common import page_setup +from src.common.common import page_setup, save_params from src.Workflow import Workflow @@ -10,3 +10,5 @@ st.title(wf.name) wf.show_parameter_section() + +save_params(params) diff --git a/content/topp_workflow_results.py b/content/topp_workflow_results.py index 687edc24..0314f348 100644 --- a/content/topp_workflow_results.py +++ b/content/topp_workflow_results.py @@ -1,5 +1,5 @@ import streamlit as st -from src.common.common import page_setup +from src.common.common import page_setup, save_params from src.Workflow import Workflow @@ -11,3 +11,4 @@ wf.show_results_section() +save_params(params) From d6c49702ff5b64f7f63992607f837abc80f1135c Mon Sep 17 00:00:00 2001 From: Arslan Date: Wed, 13 Nov 2024 23:17:12 +0100 Subject: [PATCH 2/4] added controllo to default-parameters.json --- default-parameters.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/default-parameters.json b/default-parameters.json index 0d1d02cc..7c084f8b 100644 --- a/default-parameters.json +++ b/default-parameters.json @@ -4,5 +4,7 @@ "2D-map-intensity-cutoff": 5000, "example-x-dimension": 10, - "example-y-dimension": 5 + "example-y-dimension": 5, + + "controllo": false } From e8dce1663bc264d7907a162e43c358ce7f16abe6 Mon Sep 17 00:00:00 2001 From: Arslan Date: Thu, 14 Nov 2024 00:27:07 +0100 Subject: [PATCH 3/4] check in setup oage captcha solve or not --- src/common/common.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/common/common.py b/src/common/common.py index b3e3d242..a36adf5c 100644 --- a/src/common/common.py +++ b/src/common/common.py @@ -228,10 +228,15 @@ def page_setup(page: str = "") -> dict[str, Any]: params = render_sidebar(page) # If run in hosted mode, show captcha as long as it has not been solved - if not "local" in sys.argv: - if "controllo" not in st.session_state: - # Apply captcha by calling the captcha_control function - captcha_control() + #if not "local" in sys.argv: + # if "controllo" not in st.session_state: + # # Apply captcha by calling the captcha_control function + # captcha_control() + + # If run in hosted mode, show captcha as long as it has not been solved + if 'controllo' not in st.session_state or params["controllo"] == False: + # Apply captcha by calling the captcha_control function + captcha_control() return params From f6f4eee0a353db5f86834fa91d4e45f708396566 Mon Sep 17 00:00:00 2001 From: Arslan Date: Thu, 14 Nov 2024 00:52:22 +0100 Subject: [PATCH 4/4] Revert "every page save params of current session/ during exec at the end" This reverts commit 3dfef2f57f7b9cec61d76a075f8c595613bb46a0. --- content/documentation.py | 9 +++------ content/download_section.py | 8 +++----- content/quickstart.py | 6 ++---- content/raw_data_viewer.py | 5 +---- content/run_example_workflow.py | 5 +---- content/topp_workflow_execution.py | 3 +-- content/topp_workflow_file_upload.py | 3 +-- content/topp_workflow_parameter.py | 4 +--- content/topp_workflow_results.py | 3 +-- 9 files changed, 14 insertions(+), 32 deletions(-) diff --git a/content/documentation.py b/content/documentation.py index 8dc95ebb..c308213b 100644 --- a/content/documentation.py +++ b/content/documentation.py @@ -1,9 +1,9 @@ import streamlit as st -from src.common.common import page_setup, save_params +from src.common.common import page_setup from pathlib import Path from docs.toppframework import content as topp_framework_content -params = page_setup() +page_setup() st.title("Documentation") @@ -106,7 +106,4 @@ if page == pages[5]: with open(Path("docs", "deployment.md"), "r", encoding="utf-8") as f: content = f.read() - st.markdown(content) - - -save_params(params) + st.markdown(content) \ No newline at end of file diff --git a/content/download_section.py b/content/download_section.py index 0ce00738..8856a7b3 100644 --- a/content/download_section.py +++ b/content/download_section.py @@ -3,10 +3,10 @@ from pathlib import Path import shutil -from src.common.common import page_setup, save_params +from src.common.common import page_setup from zipfile import ZipFile, ZIP_DEFLATED -params = page_setup() +page_setup() # Define output folder here; all subfolders will be handled as downloadable # directories @@ -71,6 +71,4 @@ with columns[2]: if st.button(f"🗑️ {directory.name}", use_container_width=True): shutil.rmtree(directory) - st.rerun() - -save_params(params) + st.rerun() \ No newline at end of file diff --git a/content/quickstart.py b/content/quickstart.py index 43e3e4f7..a2a8eac8 100644 --- a/content/quickstart.py +++ b/content/quickstart.py @@ -21,9 +21,9 @@ from pathlib import Path import streamlit as st -from src.common.common import page_setup, v_space, save_params +from src.common.common import page_setup, v_space -params = page_setup(page="main") +page_setup(page="main") st.markdown("# 👋 Quick Start") st.markdown("## Template for OpenMS web apps using the **streamlit** framework") @@ -163,5 +163,3 @@ label="How to run any command line tool as subprocess from within the OpenMS web app.", icon="➡️", ) - -save_params(params) diff --git a/content/raw_data_viewer.py b/content/raw_data_viewer.py index a5c0415e..d788e25d 100755 --- a/content/raw_data_viewer.py +++ b/content/raw_data_viewer.py @@ -2,7 +2,7 @@ import streamlit as st -from src.common.common import page_setup, save_params +from src.common.common import page_setup from src import view @@ -42,6 +42,3 @@ view.view_spectrum() with tabs[2]: view.view_bpc_tic() - - -save_params(params) diff --git a/content/run_example_workflow.py b/content/run_example_workflow.py index 5d827965..49e70e9c 100755 --- a/content/run_example_workflow.py +++ b/content/run_example_workflow.py @@ -56,7 +56,4 @@ -mzmlfileworkflow.result_section(result_dir) - - -save_params(params) +mzmlfileworkflow.result_section(result_dir) \ No newline at end of file diff --git a/content/topp_workflow_execution.py b/content/topp_workflow_execution.py index fbf852d0..4da0f3a7 100644 --- a/content/topp_workflow_execution.py +++ b/content/topp_workflow_execution.py @@ -1,5 +1,5 @@ import streamlit as st -from src.common.common import page_setup, save_params +from src.common.common import page_setup from src.Workflow import Workflow @@ -11,5 +11,4 @@ wf.show_execution_section() -save_params(params) diff --git a/content/topp_workflow_file_upload.py b/content/topp_workflow_file_upload.py index 86c5f1f4..de8916a8 100644 --- a/content/topp_workflow_file_upload.py +++ b/content/topp_workflow_file_upload.py @@ -1,5 +1,5 @@ import streamlit as st -from src.common.common import page_setup, save_params +from src.common.common import page_setup from src.Workflow import Workflow @@ -11,5 +11,4 @@ wf.show_file_upload_section() -save_params(params) diff --git a/content/topp_workflow_parameter.py b/content/topp_workflow_parameter.py index 2e316848..cb0573d6 100644 --- a/content/topp_workflow_parameter.py +++ b/content/topp_workflow_parameter.py @@ -1,5 +1,5 @@ import streamlit as st -from src.common.common import page_setup, save_params +from src.common.common import page_setup from src.Workflow import Workflow @@ -10,5 +10,3 @@ st.title(wf.name) wf.show_parameter_section() - -save_params(params) diff --git a/content/topp_workflow_results.py b/content/topp_workflow_results.py index 0314f348..687edc24 100644 --- a/content/topp_workflow_results.py +++ b/content/topp_workflow_results.py @@ -1,5 +1,5 @@ import streamlit as st -from src.common.common import page_setup, save_params +from src.common.common import page_setup from src.Workflow import Workflow @@ -11,4 +11,3 @@ wf.show_results_section() -save_params(params)