From cd4827a4264501a34c563a96130d50d6375189fd Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Tue, 24 Jun 2025 10:27:35 -0700 Subject: [PATCH 1/6] adding necessary components --- Dockerfile | 19 +++++++++++++++++++ Makefile | 17 +++++++++++++++++ docker-compose-dev.yml | 5 +++++ docker-compose.yml | 33 +++++++++++++++++++++++++++++++++ run_server.sh | 4 ++++ 5 files changed, 78 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-compose-dev.yml create mode 100644 docker-compose.yml create mode 100755 run_server.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d879a3c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM ubuntu:22.04 +MAINTAINER Mingxun Wang "mwang87@gmail.com" + +RUN apt-get update && apt-get install -y build-essential libarchive-dev wget vim git-core + +# Install Mamba +ENV CONDA_DIR /opt/conda +RUN wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O ~/miniforge.sh && /bin/bash ~/miniforge.sh -b -p /opt/conda +ENV PATH=$CONDA_DIR/bin:$PATH + +# Adding to bashrc +RUN echo "export PATH=$CONDA_DIR:$PATH" >> ~/.bashrc + +# Creating conda env +COPY environment.yml . +RUN mamba env create -f environment.yml + +COPY . /app +WORKDIR /app diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f2217e7 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +server-compose-build-nocache: + docker-compose --compatibility build --no-cache + +server-compose-interactive: + docker-compose --compatibility build + docker-compose --compatibility -f docker-compose.yml -f docker-compose-dev.yml up + +server-compose: + docker-compose --compatibility build + docker-compose --compatibility -f docker-compose.yml -f docker-compose-dev.yml up -d + +server-compose-production: + docker-compose --compatibility build + docker-compose --compatibility -f docker-compose.yml up -d + +attach: + docker exec -i -t template-streamlit /bin/bash diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml new file mode 100644 index 0000000..26b0a76 --- /dev/null +++ b/docker-compose-dev.yml @@ -0,0 +1,5 @@ +version: '3' +services: + microspotter-streamlit: + ports: + - "5000:5000" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7e6bdd4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +version: '3' +services: + microspotter-streamlit: + build: + context: . + dockerfile: Dockerfile + container_name: microspotter-streamlit + volumes: + - ./logs:/app/logs:rw + networks: + - default + - nginx-net + restart: unless-stopped + command: /app/run_server.sh + logging: + driver: json-file + options: + max-size: "10m" # Maximum size of a single log file + max-file: "3" # Maximum number of log files to keep (rotates after 3 files) + deploy: + resources: + limits: + memory: 8000M + environment: + VIRTUAL_HOST: microspotter.wanglab.science + VIRTUAL_PORT: 5000 + LETSENCRYPT_HOST: microspotter.wanglab.science + LETSENCRYPT_EMAIL: mwang87@gmail.com + +networks: + nginx-net: + external: + name: nginx-net \ No newline at end of file diff --git a/run_server.sh b/run_server.sh new file mode 100755 index 0000000..8a82a7e --- /dev/null +++ b/run_server.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +source activate microspotreader +streamlit run run.py --server.port 5000 --server.address 0.0.0.0 \ No newline at end of file From 9596f8f52dfe9a124a120c9185fb0d984021626f Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Tue, 24 Jun 2025 10:33:16 -0700 Subject: [PATCH 2/6] cleanup --- environment.yml | 31 ++++++++++++++--------------- pages/1_Image_Analysis.py | 1 - run.py | 42 --------------------------------------- 3 files changed, 15 insertions(+), 59 deletions(-) diff --git a/environment.yml b/environment.yml index 4dcd201..a49102d 100644 --- a/environment.yml +++ b/environment.yml @@ -2,21 +2,20 @@ name: microspotreader channels: - defaults dependencies: - - bzip2=1.0.8=he774522_0 - - ca-certificates=2023.08.22=haa95532_0 - - libffi=3.4.4=hd77b12b_0 - - openssl=3.0.12=h2bbff1b_0 - - pip=23.3=py311haa95532_0 - - plotly=5.9.0=py311haa95532_0 - - python=3.11.5=he1021f5_0 - - setuptools=68.0.0=py311haa95532_0 - - sqlite=3.41.2=h2bbff1b_0 - - tk=8.6.12=h2bbff1b_0 - - vc=14.2=h21ff451_1 - - vs2015_runtime=14.27.29016=h5e58377_2 - - wheel=0.41.2=py311haa95532_0 - - xz=5.4.2=h8cc25b3_0 - - zlib=1.2.13=h8cc25b3_0 + - bzip2=1.0.8 + - ca-certificates=2023.08.22 + - libffi=3.4.4 + - openssl=3.0.12 + - pip=23.3 + - plotly=5.9.0 + - python=3.11.5 + - setuptools=68.0.0 + - sqlite=3.41.2 + - tk=8.6.12 + - vc=14.2 + - wheel=0.41.2 + - xz=5.4.2 + - zlib=1.2.13 - pip: - altair==5.1.2 - ansi2html==1.8.0 @@ -122,4 +121,4 @@ dependencies: - werkzeug==3.0.1 - widgetsnbextension==4.0.9 - zipp==3.17.0 -prefix: C:\Users\Nomis\anaconda3\envs\microspotreader +#prefix: C:\Users\Nomis\anaconda3\envs\microspotreader diff --git a/pages/1_Image_Analysis.py b/pages/1_Image_Analysis.py index 4bada3d..c04ef00 100644 --- a/pages/1_Image_Analysis.py +++ b/pages/1_Image_Analysis.py @@ -6,7 +6,6 @@ import src.streamlit.image_analysis as stim import streamlit as st from src.microspotreader import * -from src.streamlit.DataStorage import DataStorage from src.streamlit.general import * # Sets up basic page layout diff --git a/run.py b/run.py index fb2ce47..160429b 100644 --- a/run.py +++ b/run.py @@ -1,50 +1,8 @@ from __future__ import annotations -import io import os import sys -import tempfile -import zipfile -from collections.abc import MutableSequence -from copy import copy, deepcopy -from dataclasses import dataclass, field -from pathlib import Path -from typing import TYPE_CHECKING -import imageio.v3 as iio -import matplotlib.patheffects as pe -import matplotlib.pyplot as plt -import numpy as np -import pandas as pd -import pyopenms as oms -import seaborn as sns -from matplotlib.patches import Patch -from numba import njit -from scipy.ndimage import gaussian_filter1d -from scipy.signal import find_peaks, savgol_filter -from scipy.stats import pearsonr -from skimage.color import rgb2gray -from skimage.draw import disk -from skimage.feature import canny, peak_local_max -from skimage.filters import threshold_otsu -from skimage.filters.rank import equalize -from skimage.morphology import ( - binary_dilation, - binary_opening, - disk, - reconstruction, - remove_small_objects, - skeletonize, -) -from skimage.transform import ( - hough_circle, - hough_circle_peaks, - hough_line, - hough_line_peaks, -) -from skimage.util import img_as_ubyte, invert - -import streamlit as st import streamlit.web.cli as stcli From 8b124b8b8de78e7f3dc010033cda02775439dc5e Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Tue, 24 Jun 2025 15:01:07 -0700 Subject: [PATCH 3/6] bug fix --- environment.yml | 234 ++++++++++++++++++++++++------------------------ run_server.sh | 2 +- 2 files changed, 120 insertions(+), 116 deletions(-) diff --git a/environment.yml b/environment.yml index a49102d..ee79d4e 100644 --- a/environment.yml +++ b/environment.yml @@ -2,123 +2,127 @@ name: microspotreader channels: - defaults dependencies: - - bzip2=1.0.8 - - ca-certificates=2023.08.22 - - libffi=3.4.4 - - openssl=3.0.12 - - pip=23.3 + # - bzip2=1.0.8 + # - ca-certificates=2023.08.22 + # - libffi=3.4.4 + # - openssl=3.0.12 + - pip - plotly=5.9.0 - python=3.11.5 - setuptools=68.0.0 - - sqlite=3.41.2 - - tk=8.6.12 - - vc=14.2 - - wheel=0.41.2 - - xz=5.4.2 - - zlib=1.2.13 + - libglib + # - sqlite=3.41.2 + # - tk=8.6.12 + # - vc=14.2 + # - wheel=0.41.2 + # - xz=5.4.2 + # - zlib=1.2.13 - pip: - - altair==5.1.2 - - ansi2html==1.8.0 - - asttokens==2.4.1 - - attrs==23.1.0 - - backcall==0.2.0 - - blinker==1.6.3 - - cachetools==5.3.2 - - certifi==2023.7.22 - - charset-normalizer==3.3.1 - - click==8.1.7 - - colorama==0.4.6 - - comm==0.1.4 - - contourpy==1.1.1 - - cycler==0.12.1 - - dash==2.14.1 - - dash-core-components==2.0.0 - - dash-html-components==2.0.0 - - dash-table==5.0.0 - - debugpy==1.8.0 - - decorator==5.1.1 - - executing==2.0.0 - - flask==3.0.0 - - fonttools==4.43.1 - - gitdb==4.0.11 - - gitpython==3.1.40 - - idna==3.4 - - imagecodecs==2023.9.18 - - imageio==2.31.6 - - importlib-metadata==6.8.0 - - ipykernel==6.27.0 - - ipympl==0.9.3 - - ipython==8.16.1 - - ipython-genutils==0.2.0 - - ipywidgets==8.1.1 - - itsdangerous==2.1.2 - - jedi==0.19.1 - - jinja2==3.1.2 - - jsonschema==4.19.1 - - jsonschema-specifications==2023.7.1 - - jupyter-client==8.6.0 - - jupyter-core==5.5.0 - - jupyter-dash==0.4.2 - - jupyterlab-widgets==3.0.9 - - kiwisolver==1.4.5 - - lazy-loader==0.3 - - llvmlite==0.42.0 - - markdown-it-py==3.0.0 - - markupsafe==2.1.3 - - matplotlib==3.8.0 - - matplotlib-inline==0.1.6 - - mdurl==0.1.2 - - nest-asyncio==1.5.8 - - networkx==3.2 - - numba==0.59.0 - - numpy==1.26.1 - - packaging==23.2 - - pandas==2.1.2 - - parso==0.8.3 - - pexpect==4.8.0 - - pickleshare==0.7.5 - - pillow==10.0.1 - - platformdirs==4.0.0 - - prompt-toolkit==3.0.39 - - protobuf==4.24.4 - - psutil==5.9.6 - - ptyprocess==0.7.0 - - pure-eval==0.2.2 - - pyarrow==13.0.0 - - pydeck==0.8.1b0 - - pygments==2.16.1 - - pyopenms==3.1.0 - - pyparsing==3.1.1 - - python-dateutil==2.8.2 - - pytz==2023.3.post1 - - pywin32==306 - - pyzmq==25.1.1 - - referencing==0.30.2 - - requests==2.31.0 - - retrying==1.3.4 - - rich==13.6.0 - - rpds-py==0.10.6 - - scikit-image==0.22.0 - - scipy==1.11.3 - - seaborn==0.13.2 - - six==1.16.0 - - smmap==5.0.1 - - stack-data==0.6.3 - - streamlit==1.31.1 - - tenacity==8.2.3 - - tifffile==2023.9.26 - - toml==0.10.2 - - toolz==0.12.0 - - tornado==6.3.3 - - traitlets==5.12.0 - - typing-extensions==4.8.0 - - tzdata==2023.3 - - tzlocal==5.2 - - urllib3==2.0.7 - - validators==0.22.0 - - watchdog==3.0.0 - - wcwidth==0.2.8 - - werkzeug==3.0.1 - - widgetsnbextension==4.0.9 - - zipp==3.17.0 + - streamlit + - matplotlib==3.8.0 + - scipy==1.11.3 + - pandas==2.1.2 + - pyopenms==3.1.0 + - numba==0.59.0 + - seaborn==0.13.2 + - scikit-image + # - altair==5.1.2 + # - ansi2html==1.8.0 + # - asttokens==2.4.1 + # - attrs==23.1.0 + # - backcall==0.2.0 + # - blinker==1.6.3 + # - cachetools==5.3.2 + # - certifi==2023.7.22 + # - charset-normalizer==3.3.1 + # - click==8.1.7 + # - colorama==0.4.6 + # - comm==0.1.4 + # - contourpy==1.1.1 + # - cycler==0.12.1 + # - dash==2.14.1 + # - dash-core-components==2.0.0 + # - dash-html-components==2.0.0 + # - dash-table==5.0.0 + # - debugpy==1.8.0 + # - decorator==5.1.1 + # - executing==2.0.0 + # - flask==3.0.0 + # - fonttools==4.43.1 + # - gitdb==4.0.11 + # - gitpython==3.1.40 + # - idna==3.4 + # - imagecodecs==2023.9.18 + # - imageio==2.31.6 + # - importlib-metadata==6.8.0 + # - ipykernel==6.27.0 + # - ipympl==0.9.3 + # - ipython==8.16.1 + # - ipython-genutils==0.2.0 + # - ipywidgets==8.1.1 + # - itsdangerous==2.1.2 + # - jedi==0.19.1 + # - jinja2==3.1.2 + # - jsonschema==4.19.1 + # - jsonschema-specifications==2023.7.1 + # - jupyter-client==8.6.0 + # - jupyter-core==5.5.0 + # - jupyter-dash==0.4.2 + # - jupyterlab-widgets==3.0.9 + # - kiwisolver==1.4.5 + # - lazy-loader==0.3 + # - llvmlite==0.42.0 + # - markdown-it-py==3.0.0 + # - markupsafe==2.1.3 + + # - matplotlib-inline==0.1.6 + # - mdurl==0.1.2 + # - nest-asyncio==1.5.8 + # - networkx==3.2 + # - numba==0.59.0 + # - numpy==1.26.1 + # - packaging==23.2 + # - parso==0.8.3 + # - pexpect==4.8.0 + # - pickleshare==0.7.5 + # - pillow==10.0.1 + # - platformdirs==4.0.0 + # - prompt-toolkit==3.0.39 + # - protobuf==4.24.4 + # - psutil==5.9.6 + # - ptyprocess==0.7.0 + # - pure-eval==0.2.2 + # - pyarrow==13.0.0 + # - pydeck==0.8.1b0 + # - pygments==2.16.1 + # - pyparsing==3.1.1 + # - python-dateutil==2.8.2 + # - pytz==2023.3.post1 + # - pywin32==306 + # - pyzmq==25.1.1 + # - referencing==0.30.2 + # - requests==2.31.0 + # - retrying==1.3.4 + # - rich==13.6.0 + # - rpds-py==0.10.6 + # - six==1.16.0 + # - smmap==5.0.1 + # - stack-data==0.6.3 + # - streamlit==1.31.1 + # - tenacity==8.2.3 + # - tifffile==2023.9.26 + # - toml==0.10.2 + # - toolz==0.12.0 + # - tornado==6.3.3 + # - traitlets==5.12.0 + # - typing-extensions==4.8.0 + # - tzdata==2023.3 + # - tzlocal==5.2 + # - urllib3==2.0.7 + # - validators==0.22.0 + # - watchdog==3.0.0 + # - wcwidth==0.2.8 + # - werkzeug==3.0.1 + # - widgetsnbextension==4.0.9 + # - zipp==3.17.0 #prefix: C:\Users\Nomis\anaconda3\envs\microspotreader diff --git a/run_server.sh b/run_server.sh index 8a82a7e..aab5113 100755 --- a/run_server.sh +++ b/run_server.sh @@ -1,4 +1,4 @@ #!/bin/bash source activate microspotreader -streamlit run run.py --server.port 5000 --server.address 0.0.0.0 \ No newline at end of file +streamlit run Microspot_Reader.py --server.port 5000 --server.address 0.0.0.0 \ No newline at end of file From 69d87cdc144a62cb62eae75f196facbdb775be16 Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Tue, 24 Jun 2025 15:01:52 -0700 Subject: [PATCH 4/6] updating --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7e6bdd4..ecf590f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,9 +22,9 @@ services: limits: memory: 8000M environment: - VIRTUAL_HOST: microspotter.wanglab.science + VIRTUAL_HOST: microspotreader.gnps2.org VIRTUAL_PORT: 5000 - LETSENCRYPT_HOST: microspotter.wanglab.science + LETSENCRYPT_HOST: microspotreader.gnps2.org LETSENCRYPT_EMAIL: mwang87@gmail.com networks: From 4e802932fc7032b9036c18ac121171d78449a237 Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Tue, 24 Jun 2025 15:02:58 -0700 Subject: [PATCH 5/6] bug fix --- environment.yml | 112 +----------------------------------------------- 1 file changed, 1 insertion(+), 111 deletions(-) diff --git a/environment.yml b/environment.yml index ee79d4e..eb81a31 100644 --- a/environment.yml +++ b/environment.yml @@ -2,21 +2,11 @@ name: microspotreader channels: - defaults dependencies: - # - bzip2=1.0.8 - # - ca-certificates=2023.08.22 - # - libffi=3.4.4 - # - openssl=3.0.12 - pip - plotly=5.9.0 - python=3.11.5 - setuptools=68.0.0 - libglib - # - sqlite=3.41.2 - # - tk=8.6.12 - # - vc=14.2 - # - wheel=0.41.2 - # - xz=5.4.2 - # - zlib=1.2.13 - pip: - streamlit - matplotlib==3.8.0 @@ -25,104 +15,4 @@ dependencies: - pyopenms==3.1.0 - numba==0.59.0 - seaborn==0.13.2 - - scikit-image - # - altair==5.1.2 - # - ansi2html==1.8.0 - # - asttokens==2.4.1 - # - attrs==23.1.0 - # - backcall==0.2.0 - # - blinker==1.6.3 - # - cachetools==5.3.2 - # - certifi==2023.7.22 - # - charset-normalizer==3.3.1 - # - click==8.1.7 - # - colorama==0.4.6 - # - comm==0.1.4 - # - contourpy==1.1.1 - # - cycler==0.12.1 - # - dash==2.14.1 - # - dash-core-components==2.0.0 - # - dash-html-components==2.0.0 - # - dash-table==5.0.0 - # - debugpy==1.8.0 - # - decorator==5.1.1 - # - executing==2.0.0 - # - flask==3.0.0 - # - fonttools==4.43.1 - # - gitdb==4.0.11 - # - gitpython==3.1.40 - # - idna==3.4 - # - imagecodecs==2023.9.18 - # - imageio==2.31.6 - # - importlib-metadata==6.8.0 - # - ipykernel==6.27.0 - # - ipympl==0.9.3 - # - ipython==8.16.1 - # - ipython-genutils==0.2.0 - # - ipywidgets==8.1.1 - # - itsdangerous==2.1.2 - # - jedi==0.19.1 - # - jinja2==3.1.2 - # - jsonschema==4.19.1 - # - jsonschema-specifications==2023.7.1 - # - jupyter-client==8.6.0 - # - jupyter-core==5.5.0 - # - jupyter-dash==0.4.2 - # - jupyterlab-widgets==3.0.9 - # - kiwisolver==1.4.5 - # - lazy-loader==0.3 - # - llvmlite==0.42.0 - # - markdown-it-py==3.0.0 - # - markupsafe==2.1.3 - - # - matplotlib-inline==0.1.6 - # - mdurl==0.1.2 - # - nest-asyncio==1.5.8 - # - networkx==3.2 - # - numba==0.59.0 - # - numpy==1.26.1 - # - packaging==23.2 - # - parso==0.8.3 - # - pexpect==4.8.0 - # - pickleshare==0.7.5 - # - pillow==10.0.1 - # - platformdirs==4.0.0 - # - prompt-toolkit==3.0.39 - # - protobuf==4.24.4 - # - psutil==5.9.6 - # - ptyprocess==0.7.0 - # - pure-eval==0.2.2 - # - pyarrow==13.0.0 - # - pydeck==0.8.1b0 - # - pygments==2.16.1 - # - pyparsing==3.1.1 - # - python-dateutil==2.8.2 - # - pytz==2023.3.post1 - # - pywin32==306 - # - pyzmq==25.1.1 - # - referencing==0.30.2 - # - requests==2.31.0 - # - retrying==1.3.4 - # - rich==13.6.0 - # - rpds-py==0.10.6 - # - six==1.16.0 - # - smmap==5.0.1 - # - stack-data==0.6.3 - # - streamlit==1.31.1 - # - tenacity==8.2.3 - # - tifffile==2023.9.26 - # - toml==0.10.2 - # - toolz==0.12.0 - # - tornado==6.3.3 - # - traitlets==5.12.0 - # - typing-extensions==4.8.0 - # - tzdata==2023.3 - # - tzlocal==5.2 - # - urllib3==2.0.7 - # - validators==0.22.0 - # - watchdog==3.0.0 - # - wcwidth==0.2.8 - # - werkzeug==3.0.1 - # - widgetsnbextension==4.0.9 - # - zipp==3.17.0 -#prefix: C:\Users\Nomis\anaconda3\envs\microspotreader + - scikit-image \ No newline at end of file From a15bd768f8687cd102ff75ad99f32c9474f2fc14 Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Thu, 3 Jul 2025 08:39:41 -0700 Subject: [PATCH 6/6] adding image codec --- environment.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index eb81a31..d21e194 100644 --- a/environment.yml +++ b/environment.yml @@ -15,4 +15,5 @@ dependencies: - pyopenms==3.1.0 - numba==0.59.0 - seaborn==0.13.2 - - scikit-image \ No newline at end of file + - scikit-image + - imagecodecs==2023.9.18