Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build-windows-executable-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ jobs:

- name: Create .bat file
run: |

echo '@echo off' > ${{ env.APP_NAME }}.bat
Comment on lines +261 to 262
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove extra space

echo '' >> ${{ env.APP_NAME }}.bat
echo 'REM Create .streamlit directory in user''s home if it doesn''t exist' >> ${{ env.APP_NAME }}.bat
Expand All @@ -266,6 +267,8 @@ jobs:
echo 'REM Create credentials.toml with empty email to disable email prompt' >> ${{ env.APP_NAME }}.bat
echo 'copy /Y ".streamlit\credentials.toml" "%USERPROFILE%\.streamlit\credentials.toml" > nul' >> ${{ env.APP_NAME }}.bat
echo '' >> ${{ env.APP_NAME }}.bat
echo 'start /min .\python-${{ env.PYTHON_VERSION }}\python -m redis-server' > ${{ env.APP_NAME }}.bat
echo 'start /min .\python-${{ env.PYTHON_VERSION }}\python -m rq worker --with-scheduler' >> ${{ env.APP_NAME }}.bat
echo 'start /min .\python-${{ env.PYTHON_VERSION }}\python -m streamlit run app.py local' >> ${{ env.APP_NAME }}.bat
Comment on lines +270 to 272
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Prevent Accidental File Overwrite with Correct Redirection

In the updated batch file section, the command on line 270 uses the single redirection operator (>). This causes the file to be overwritten—erasing previously appended commands such as the initial setup instructions. To ensure that all commands remain in the resulting batch file, change the redirection operator from > to >>.

Below is the suggested fix:

-echo 'start /min .\python-${{ env.PYTHON_VERSION }}\python -m redis-server' > ${{ env.APP_NAME }}.bat 
+echo 'start /min .\python-${{ env.PYTHON_VERSION }}\python -m redis-server' >> ${{ env.APP_NAME }}.bat 
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo 'start /min .\python-${{ env.PYTHON_VERSION }}\python -m redis-server' > ${{ env.APP_NAME }}.bat
echo 'start /min .\python-${{ env.PYTHON_VERSION }}\python -m rq worker --with-scheduler' >> ${{ env.APP_NAME }}.bat
echo 'start /min .\python-${{ env.PYTHON_VERSION }}\python -m streamlit run app.py local' >> ${{ env.APP_NAME }}.bat
echo 'start /min .\python-${{ env.PYTHON_VERSION }}\python -m redis-server' >> ${{ env.APP_NAME }}.bat
echo 'start /min .\python-${{ env.PYTHON_VERSION }}\python -m rq worker --with-scheduler' >> ${{ env.APP_NAME }}.bat
echo 'start /min .\python-${{ env.PYTHON_VERSION }}\python -m streamlit run app.py local' >> ${{ env.APP_NAME }}.bat
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 270-270: trailing spaces

(trailing-spaces)


- name: Create All-in-one executable folder
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ RUN echo "0 3 * * * /root/miniforge3/envs/streamlit-env/bin/python /app/clean-up
RUN echo "#!/bin/bash" > /app/entrypoint.sh && \
echo "source /root/miniforge3/bin/activate streamlit-env" >> /app/entrypoint.sh && \
echo "service cron start" >> /app/entrypoint.sh && \
echo "redis-server" >> /app/entrypoint.sh && \
echo "rq worker --with-scheduler" >> /app/entrypoint.sh && \
echo "streamlit run app.py" >> /app/entrypoint.sh
# make the script executable
RUN chmod +x /app/entrypoint.sh
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile_simple
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ RUN echo "0 3 * * * /root/miniforge3/envs/streamlit-env/bin/python /app/clean-up
RUN echo "#!/bin/bash" > /app/entrypoint.sh
RUN echo "source /root/miniforge3/bin/activate streamlit-env" >> /app/entrypoint.sh && \
echo "service cron start" >> /app/entrypoint.sh && \
echo "redis-server" >> /app/entrypoint.sh && \
echo "rq worker --with-scheduler" >> /app/entrypoint.sh && \
echo "streamlit run app.py" >> /app/entrypoint.sh
# make the script executable
RUN chmod +x /app/entrypoint.sh
Expand Down
4 changes: 3 additions & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ Create and activate the conda environment:

Run the app via streamlit command in the terminal. *local* and *online* mode can be toggled in the settings.json. Learn more about *local* and *online* mode in the documentation page 📖 **OpenMS Template App**.

`streamlit run app.py`
1. Open a new terminal and run `redis-server`
2. On another terminal run `rq worker --with-scheduler` (multiple workers can be spawned)
3. Finally start the application `streamlit run app.py`

## Docker

Expand Down
4 changes: 3 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ dependencies:
- captcha==0.5.0
- pyopenms_viz==1.0.0
- streamlit-js-eval
- psutil==7.0.0
- psutil==7.0.0
- redis==5.2.1
- rq==2.1.0
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ plotly==5.22.0
captcha==0.5.0
pyopenms_viz==1.0.0
streamlit-js-eval
psutil==7.0.0
psutil==7.0.0
redis==5.2.1
rq==2.1.0
28 changes: 20 additions & 8 deletions src/Workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import plotly.express as px
from src.common.common import show_fig


class Workflow(WorkflowManager):
# Setup pages for upload, parameter, execution and results.
# For layout use any streamlit components such as tabs (as shown in example), columns, or even expanders.
Expand Down Expand Up @@ -70,8 +69,10 @@ def execution(self) -> None:

# Run FeatureFinderMetabo tool with input and output files.
self.logger.log("Detecting features...")
self.executor.run_topp(
"FeatureFinderMetabo", input_output={"in": in_mzML, "out": out_ffm}
featureFinderMetaboJob = self.queue.enqueue(
self.executor.run_topp,
"FeatureFinderMetabo",
input_output={"in": in_mzML, "out": out_ffm}
)

# Prepare input and output files for feature linking
Expand All @@ -82,17 +83,28 @@ def execution(self) -> None:

# Run FeatureLinkerUnlabaeledKD with all feature maps passed at once
self.logger.log("Linking features...")
self.executor.run_topp(
"FeatureLinkerUnlabeledKD", input_output={"in": in_fl, "out": out_fl}
featureLinkerUnlabeledKDJob = self.queue.enqueue(
self.executor.run_topp,
"FeatureLinkerUnlabeledKD",
input_output={"in": in_fl, "out": out_fl},
depends_on=featureFinderMetaboJob
)
self.logger.log("Exporting consensus features to pandas DataFrame...")
self.executor.run_python(
"export_consensus_feature_df", input_output={"in": out_fl[0]}
exportConsensusFeatureJob = self.queue.enqueue(
self.executor.run_python,
"export_consensus_feature_df",
input_output={"in": out_fl[0]},
depends_on=featureLinkerUnlabeledKDJob
)
# Delete pid dir path to indicate workflow is done
self.queue.enqueue(
self.executor.end_run,
depends_on=exportConsensusFeatureJob
)
# Check if adduct detection should be run.
if self.params["run-python-script"]:
# Example for a custom Python tool, which is located in src/python-tools.
self.executor.run_python("example", {"in": in_mzML})
self.queue.enqueue(self.executor.run_python, "example", {"in": in_mzML})

@st.fragment
def results(self) -> None:
Expand Down
9 changes: 8 additions & 1 deletion src/workflow/CommandExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def run_command(self, command: list[str]) -> None:
stdout, stderr = process.communicate()

# Cleanup PID file
pid_file_path.unlink()
if pid_file_path.exists():
pid_file_path.unlink()

end_time = time.time()
execution_time = end_time - start_time
Expand Down Expand Up @@ -210,6 +211,12 @@ def stop(self) -> None:
shutil.rmtree(self.pid_dir, ignore_errors=True)
self.logger.log("Workflow stopped.")

def end_run(self) -> None:
"""
Cleans up the PID directory by removing all PID files.
"""
shutil.rmtree(self.pid_dir, ignore_errors=True)

def run_python(self, script_file: str, input_output: dict = {}) -> None:
"""
Executes a specified Python script with dynamic input and output parameters,
Expand Down
5 changes: 3 additions & 2 deletions src/workflow/WorkflowManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
import streamlit as st
import shutil
import time
from rq import Queue
from redis import Redis

class WorkflowManager:
# Core workflow logic using the above classes
def __init__(self, name: str, workspace: str):
self.name = name
self.queue = Queue(connection=Redis())
self.workflow_dir = Path(workspace, name.replace(" ", "-").lower())
self.file_manager = FileManager(self.workflow_dir)
self.logger = Logger(self.workflow_dir)
Expand Down Expand Up @@ -51,8 +54,6 @@ def workflow_process(self) -> None:
self.logger.log("WORKFLOW FINISHED")
except Exception as e:
self.logger.log(f"ERROR: {e}")
# Delete pid dir path to indicate workflow is done
shutil.rmtree(self.executor.pid_dir, ignore_errors=True)

def show_file_upload_section(self) -> None:
"""
Expand Down
1 change: 0 additions & 1 deletion test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pathlib import Path
import shutil


@pytest.fixture
def launch(request):
test = AppTest.from_file(request.param)
Expand Down