diff --git a/src/workflow/StreamlitUI.py b/src/workflow/StreamlitUI.py index 58a9b328..892cec82 100644 --- a/src/workflow/StreamlitUI.py +++ b/src/workflow/StreamlitUI.py @@ -989,10 +989,8 @@ def parameter_section(self, custom_parameter_function) -> None: f.write(up.read().decode("utf-8")) streamlit_js_eval(js_expressions="parent.window.location.reload()") - def execution_section(self, start_workflow_function) -> None: - with st.expander("**Summary**"): - st.markdown(self.export_parameters_markdown()) - + @st.fragment(run_every=5) + def show_log(self, start_workflow_function): c1, c2 = st.columns(2) # Select log level, this can be changed at run time or later without re-running the workflow log_level = c1.selectbox( @@ -1004,6 +1002,7 @@ def execution_section(self, start_workflow_function) -> None: st.rerun() elif c1.button("Start Workflow", type="primary", use_container_width=True): start_workflow_function() + time.sleep(3) st.rerun() log_path = Path(self.workflow_dir, "logs", log_level.replace(" ", "-") + ".log") if log_path.exists(): @@ -1028,6 +1027,13 @@ def execution_section(self, start_workflow_function) -> None: st.error("**Errors occurred, check log file.**") st.code(content, language="neon", line_numbers=False) + + def execution_section(self, start_workflow_function) -> None: + with st.expander("**Summary**"): + st.markdown(self.export_parameters_markdown()) + + self.show_log(start_workflow_function) + def results_section(self, custom_results_function) -> None: custom_results_function() diff --git a/src/workflow/WorkflowManager.py b/src/workflow/WorkflowManager.py index 426e6eb1..157226de 100644 --- a/src/workflow/WorkflowManager.py +++ b/src/workflow/WorkflowManager.py @@ -32,6 +32,10 @@ def start_workflow(self) -> None: Starts the workflow process and adds its process id to the pid directory. The workflow itself needs to be a process, otherwise streamlit will wait for everything to finish before updating the UI again. """ + # Catch double presses of the button while app is in frozen state + if self.executor.pid_dir.exists(): + return + # Delete the log file if it already exists shutil.rmtree(Path(self.workflow_dir, "logs"), ignore_errors=True) # Start workflow process @@ -40,8 +44,6 @@ def start_workflow(self) -> None: # Add workflow process id to pid dir self.executor.pid_dir.mkdir() Path(self.executor.pid_dir, str(workflow_process.pid)).touch() - time.sleep(3) - st.rerun() def workflow_process(self) -> None: """