Skip to content

Commit

Permalink
Merge pull request #25 from instituteofcancerresearch/docker
Browse files Browse the repository at this point in the history
Docker
  • Loading branch information
bkmarzouk authored Nov 23, 2023
2 parents e654687 + 8515433 commit c2e6a7d
Show file tree
Hide file tree
Showing 22 changed files with 120 additions and 355 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Upload to Docker Hub

on:
push:
branches:
- main

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: icrsc/soprano:latest
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,8 @@ app_sources/
!app_sources/immunopeptidomes/.gitkeep

# Ignore release cache file
src/SOPRANO/data/ensembl.releases
src/SOPRANO/data/ensembl.releases

# Ensembl downloads
ensembl_downloads/**/*.fa
ensembl_downloads/**/*.fa.gz
60 changes: 60 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
FROM condaforge/mambaforge:23.3.1-1 as conda

WORKDIR /app

# Construct conda environment and clean up cache files
COPY src/SOPRANO/local.yml ./
RUN mamba env create -f local.yml --name soprano && \
mamba clean -afy && \
rm local.yml

# Install R dependencies pulled from GH
COPY install_R_pkgs.R ./
RUN mamba run --no-capture-output -n soprano Rscript install_R_pkgs.R && \
rm install_R_pkgs.R

# Prepare Python dependencies (this could be better...)
COPY pyproject.toml ./
RUN sed -i '71,84d' pyproject.toml && \
sed -i '38d' pyproject.toml && \
sed -i '/name = "SOPRANO"/a version="0.0.1"' pyproject.toml && \
touch README.md

# Run pip install
COPY src ./src
RUN mamba run --no-capture-output -n soprano pip install -e . && \
mamba run --no-capture-output -n soprano pip cache purge

# Decompress transcript ID
RUN if [[ ! -f "./src/SOPRANO/data/ensemble_transcriptID.fasta" ]] ; then gunzip -v ./src/SOPRANO/data/ensemble_transcriptID.fasta.gz ; fi

# Clean up additional stuff ...
RUN rm -rf ./src/SOPRANO/immunopeptidomes/mouse && \
find ./src/SOPRANO/scripts -name "*.R" -delete && \
find -name "*.yml" -delete && \
find -name "*.gz" -delete && \
find -name '__pycache__' -type d -exec rm -rf {} + && \
cd /opt/conda && \
rm -rf conda-meta && \
find -name '__pycache__' -type d -exec rm -rf {} + && \
cd /opt/conda/lib && \
find -name 'tests' -type d -exec rm -rf {} +

# Expose port for streamlit interface
EXPOSE 8501

# Define streamlit run as entry point
ENTRYPOINT ["mamba", "run", "-n", "soprano", "streamlit", "run", "./src/SOPRANO/app.py", "--server.port=8501", "--server.address=0.0.0.0"]

# Bind mount to downloads with:
# docker run -d -p 8501:8501 --name devtest -v "$(pwd)"/ensembl_downloads/homo_sapiens:/app/ensembl_downloads/homo_sapiens soprano
# docker run -d -p 8501:8501 --name devtest -e SOPRANO_DISABLE_DOWNLOADS=True -v "$(pwd)"/ensembl_downloads/homo_sapiens:/app/ensembl_downloads/homo_sapiens soprano
# Should be visible on e.g. http://localhost:8501/

# Download and from registry:
# docker run -d -p 8501:8501 --name hub_soprano -e SOPRANO_DISABLE_DOWNLOADS=True icrsc/soprano:latest

# Mount data volumes with
# docker run -d -p 8501:8501 --name hub_soprano -e SOPRANO_DISABLE_DOWNLOADS=True -v /path/to/ensembl/downloads/:/app/ensembl_downloads/homo_sapiens icrsc/soprano:latest
# e.g.
# docker run -d -p 8501:8501 --name hub_soprano -e SOPRANO_DISABLE_DOWNLOADS=True -v "$(pwd)"/ensembl_downloads/homo_sapiens:/app/ensembl_downloads/homo_sapiens icrsc/soprano:latest
Empty file added ensembl_downloads/.gitkeep
Empty file.
14 changes: 13 additions & 1 deletion src/SOPRANO/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import pathlib

import streamlit as st
Expand Down Expand Up @@ -180,6 +181,17 @@ def with_tab_genomes(tab: DeltaGenerator):
"may be used to accelerate the annotation procedure; though this "
"is _not_ essential."
)
feature_disabled = (
os.environ.get("SOPRANO_DISABLE_DOWNLOADS", "False") == "True"
)

if feature_disabled:
st.warning(
"Downloading genome references is currently disabled at this "
"app hosting.\n\n"
"Contact the administrators [email protected] "
"to request additional genomic files to be added."
)

species_selection = st.text_input(
"Define the species",
Expand Down Expand Up @@ -210,7 +222,7 @@ def with_tab_genomes(tab: DeltaGenerator):
)
type_processed = DownloaderUIProcessing.type(type_selection)

if st.button("Download", disabled=False):
if st.button("Download", disabled=feature_disabled):
RunTab.download(
species=species_processed,
assembly=assembly_processed,
Expand Down
5 changes: 4 additions & 1 deletion src/SOPRANO/core/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,10 @@ class _GatherReferences:
sizes_done: Set[int] = set()

def _dest_directory(self, release: int):
return Directories.data(self.species) / f"{release}_{self.assembly}"
return (
Directories.ensembl_downloads(self.species)
/ f"{release}_{self.assembly}"
)

def _dest_fa_gz(self, release: int, _toplevel: bool):
return self._dest_directory(release) / filename_from_url(
Expand Down
175 changes: 0 additions & 175 deletions src/SOPRANO/examples/homo_sapiens_GRCh37.vcf

This file was deleted.

Loading

0 comments on commit c2e6a7d

Please sign in to comment.