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..ecf590f --- /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: microspotreader.gnps2.org + VIRTUAL_PORT: 5000 + LETSENCRYPT_HOST: microspotreader.gnps2.org + LETSENCRYPT_EMAIL: mwang87@gmail.com + +networks: + nginx-net: + external: + name: nginx-net \ No newline at end of file diff --git a/environment.yml b/environment.yml index 4dcd201..d21e194 100644 --- a/environment.yml +++ b/environment.yml @@ -2,124 +2,18 @@ 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 + - pip + - plotly=5.9.0 + - python=3.11.5 + - setuptools=68.0.0 + - libglib - 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 -prefix: C:\Users\Nomis\anaconda3\envs\microspotreader + - 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 + - imagecodecs==2023.9.18 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 diff --git a/run_server.sh b/run_server.sh new file mode 100755 index 0000000..aab5113 --- /dev/null +++ b/run_server.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +source activate microspotreader +streamlit run Microspot_Reader.py --server.port 5000 --server.address 0.0.0.0 \ No newline at end of file