Skip to content

Commit

Permalink
Update docker demo
Browse files Browse the repository at this point in the history
  • Loading branch information
DoraDong-2023 committed Oct 1, 2024
1 parent 6acba27 commit 4fa1d89
Show file tree
Hide file tree
Showing 17 changed files with 317 additions and 122 deletions.
33 changes: 25 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
FROM nvidia/cuda:12.1.0-base-ubuntu22.04
FROM nvidia/cuda:12.6.0-base-ubuntu22.04

# Install Python, Node.js, miniconda, dependencies
RUN apt-get update && apt-get install -y \
python3 \
python3.10 \
python3.10-distutils \
python3.10-venv \
python3.10-dev \
python3-pip \
bash \
net-tools \
iputils-ping \
curl \
git \
wget \
gfortran \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Upgrade pip to the latest version
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 \
&& python3.10 -m pip install --upgrade pip
RUN python3.10 --version

# Install Conda
RUN curl -sLo /miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& bash /miniconda.sh -b -p /miniconda \
Expand All @@ -28,7 +37,7 @@ WORKDIR /app
ARG LIB

# Copy the backend application
COPY src/requirements.txt /app/src/requirements.txt
COPY requirements.txt /app/requirements.txt
COPY src/LICENSE /app/src/LICENSE
COPY src/Git2APP /app/src/Git2APP
COPY src/R2APP /app/src/R2APP
Expand All @@ -38,20 +47,24 @@ COPY src/deploy /app/src/deploy
COPY src/gpt /app/src/gpt
COPY src/inference /app/src/inference
COPY src/models /app/src/models
COPY src/plot /app/src/plot
COPY src/prompt /app/src/prompt
COPY src/report /app/src/report
COPY src/scripts /app/src/scripts
COPY src/retrievers /app/src/retrievers
COPY images /app/images
#COPY src/tmp /app/src/tmp
COPY src/data/standard_process/${LIB}/ /app/src/data/standard_process/${LIB}/
COPY src/hugging_models/retriever_model_finetuned/${LIB}/ /app/src/hugging_models/retriever_model_finetuned/${LIB}/
COPY data/standard_process/${LIB}/ /app/data/standard_process/${LIB}/
COPY data/autocoop/${LIB}/ /app/data/autocoop/${LIB}/
COPY data/conversations/ /app/data/conversations/
COPY data/others-data/ /app/data/others-data/
COPY hugging_models/retriever_model_finetuned/${LIB}/ /app/hugging_models/retriever_model_finetuned/${LIB}/
COPY docker_utils/ /app/docker_utils/

# mkdir tmp
RUN mkdir -p /app/src/tmp

# Install Python dependencies
RUN pip3 install --no-cache-dir -r /app/docker_utils/${LIB}/requirements.txt
RUN python3.10 -m pip install --no-cache-dir -r /app/docker_utils/${LIB}/requirements.txt

# Install dependencies from environment.yml if it exists
RUN if [ -f /app/docker_utils/${LIB}/environment.yml ]; then \
Expand All @@ -67,7 +80,11 @@ RUN if [ -f /app/docker_utils/${LIB}/requirements.sh ]; then \
COPY chatbot_ui_biomania/ /app/chatbot_ui_biomania/

# Install node modules and build the front-end
RUN cd /app/chatbot_ui_biomania && npm install && npm run build
# RUN cd /app/chatbot_ui_biomania && npm install && npm run build
RUN cd /app/chatbot_ui_biomania && \
npm install [email protected] [email protected] \
npm install && \
npm run build

# run the start script
RUN chmod +x /app/docker_utils/${LIB}/docker_start_script.sh
Expand Down
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<h1 style="margin: 0; white-space: nowrap;">BioMANIA</h1>
</div>

[![Demo](https://img.shields.io/badge/Demo-BioMANIA-blue?style=flat&logo=appveyor)](https://biomania.ngrok.io/en)
[![Paper](https://img.shields.io/badge/Paper-burgundy?style=flat&logo=arxiv)](https://www.biorxiv.org/content/10.1101/2023.10.29.564479)
[![GitHub stars](https://img.shields.io/github/stars/batmen-lab/BioMANIA?style=social)](https://github.com/batmen-lab/BioMANIA)
[![Documentation Status](https://img.shields.io/readthedocs/biomania/latest?style=flat&logo=readthedocs&label=Doc)](https://biomania.readthedocs.io/en/latest/?badge=latest)
Expand Down Expand Up @@ -46,11 +47,14 @@ We also offer a command-line interface (CLI) demo through the terminal.

# Web access online demo

We provide a colab demo [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/14K4562oeesEz5qMoXmjv9gW_4VeLh6_U?usp=sharing) and an [online demo](https://biomania.ngrok.io/en) hosted on our server! (240925-Notice the connection to server demo might be unstable according to the server network condition, we will update the deployment way later)
We provide [![Online Demo](https://img.shields.io/badge/Demo-BioMANIA-blue?style=flat&logo=appveyor)](https://biomania.ngrok.io/en)
hosted on our server!

(240929-For Online Demo, note that when multiple user are using, there might be delay in connection. We will check the demo running everyday, issue (if any) will be fixed in the next day. It is recommended to ask question in English in this time, as the corpus is designed for English and thus results will be more accurate.)

# Quick start

We provide several ways to run the service: terminal CLI, Docker, railway, python script, colab demo. Among those, terminal CLI is the easiest way to start. \
We provide several ways to run the service: python script, terminal CLI, Docker, colab demo. Among those, terminal CLI is the easiest way to start. \

## Setup dataset and models
```bash
Expand All @@ -64,20 +68,20 @@ echo "GITHUB_TOKEN=your_github_token" >> .env
# - data/standard_process/{LIB} and
# - hugging_models/retriever_model_finetuned/{LIB} and
# - ../../resources/
pip install gdown==5.1.0
pip install gdown
gdown https://drive.google.com/uc?id=1nT28pIJ_dsdvi2yD8ffWt_aePXsSWdqI
sh download_data_model.sh
# setup the PYTHONPATH
export PYTHONPATH=$PYTHONPATH:$(pwd)
```

## Run with terminal CLI or gradio app
## Run with terminal CLI or gradio app (stable on Linux)

```bash
# CLI service quick start!
python -m BioMANIA.deploy.cli_demo
# or gradio app. (TODO 240509: Images showing are under developing!)
python -m BioMANIA.deploy.cli_gradio
#python -m BioMANIA.deploy.cli_gradio
```

## Run with Docker
Expand All @@ -86,15 +90,16 @@ For ease of use, we provide Docker images for several tools. You can refer the d

```bash
# Pull back-end service and front-end UI service with:
docker pull chatbotuibiomania/biomania-together:v1.1.9-${LIB}-cuda12.1-ubuntu22.04
# 241001 updated
sudo docker pull chatbotuibiomania/biomania-together:v1.1.12-${LIB}-cuda12.6-ubuntu22.04
```

Start service with
```bash
# run on gpu
docker run -e LIB=${LIB} -e OPENAI_API_KEY=[your_openai_api_key] --gpus all -d -p 3000:3000 chatbotuibiomania/biomania-together:v1.1.9-${LIB}-cuda12.1-ubuntu22.04
sudo docker run -e LIB=${LIB} -e OPENAI_API_KEY=[your_openai_api_key] -e GITHUB_TOKEN=[github_pat_xxx] --gpus all -d -p 3000:3000 chatbotuibiomania/biomania-together:v1.1.12-${LIB}-cuda12.6-ubuntu22.04
# or on cpu
docker run -e LIB=${LIB} -e OPENAI_API_KEY=[your_openai_api_key] -d -p 3000:3000 chatbotuibiomania/biomania-together:v1.1.9-${LIB}-cuda12.1-ubuntu22.04
sudo docker run -e LIB=${LIB} -e OPENAI_API_KEY=[your_openai_api_key] -e GITHUB_TOKEN=[github_pat_xxx] -d -p 3000:3000 chatbotuibiomania/biomania-together:v1.1.12-${LIB}-cuda12.6-ubuntu22.04
```

Then check UI service with `http://localhost:3000/en`.
Expand Down Expand Up @@ -129,7 +134,7 @@ To prepare your environment for the BioMANIA project, follow these steps:
```bash
git clone https://github.com/batmen-lab/BioMANIA.git
cd BioMANIA
conda create -n biomania python=3.10
conda create -n biomania python=3.9
conda activate biomania
pip install -r requirements.txt --index-url https://pypi.org/simple
export PYTHONPATH=$PYTHONPATH:$(pwd)
Expand Down Expand Up @@ -244,9 +249,9 @@ If you want to share your pretrained APP to others, there are two ways.
You can build docker and push to dockerhub, and share your docker image url in [our issue](https://github.com/batmen-lab/BioMANIA/issues/2). For environment setting of your tool, please refer to `BioMANIA/docker_utils/{LIB}/` to add the env files, or modify the Dockerfile to build your environment.
```bash
# cd BioMANIA
docker build --build-arg LIB=[your_tool_name] -t [docker_image_name] -f Dockerfile ./
sudo docker build --build-arg LIB=[your_tool_name] -t [docker_image_name] -f Dockerfile ./
# (optional)push to docker
docker push [your_docker_repo]/[docker_image_name]:[tag]
sudo docker push [your_docker_repo]/[docker_image_name]:[tag]
```

Notice if you want to include some data inside the docker, please modify the `Dockerfile` carefully to copy the folders to `/app`. Also add your PyPI or Git pip install url to the `requirements.txt` before your packaging for docker.
Expand All @@ -270,9 +275,9 @@ Thank you for choosing BioMANIA. We hope this guide assists you in navigating th


## **Version History**
- v1.1.12 (2024-09-25)
- Update code scripts which are aligned with paper.
- Will renew the data, docker, scripts for generating report, documents for Git2APP, R2APP soon.
- v1.1.12 (2024-10-01)
- Update code scripts & upload data and models & update docker which are aligned with paper.
- Will renew the scripts for generating report, documents for Git2APP, R2APP soon.

view [version_history](./docs/version_history.md) for more details!

Expand Down
20 changes: 11 additions & 9 deletions chatbot_ui_biomania/components/Chat/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ export const ChatMessage: FC<Props> = memo(({ message, messageIndex, onEdit}) =>
}
}, [isEditing]);
// const libIconSrc = selectedConversation && selectedConversation.Lib && libImages[selectedConversation.Lib] ? libImages[selectedConversation.Lib] : IconRobot;
const [libIconSrc, setLibIconSrc] = useState(IconRobot);
useEffect(() => {
if (selectedConversation && selectedConversation.Lib && libImages[selectedConversation.Lib]) {
setLibIconSrc(libImages[selectedConversation.Lib]);
}
}, []);
// const [libIconSrc, setLibIconSrc] = useState<JSX.Element>(useState(IconRobot)); //;
// useEffect(() => {
// if (selectedConversation && selectedConversation.Lib && libImages[selectedConversation.Lib]) {
// setLibIconSrc(libImages[selectedConversation.Lib]);
// }
//}, []);
return (
<>
<div
Expand All @@ -122,7 +122,8 @@ export const ChatMessage: FC<Props> = memo(({ message, messageIndex, onEdit}) =>
<div className="relative m-auto flex px-4 text-xs md:max-w-2xl md:gap-6 md:py-2 lg:max-w-2xl lg:px-0 xl:max-w-3xl">
<div className="min-w-[40px] text-right">
{message.role === 'assistant' ? (
<img src={libIconSrc} alt={selectedConversation?.Lib || 'GPT'} style={{ width: 22, height: 22 }} />
//<img src={libIconSrc} alt={selectedConversation?.Lib || 'GPT'} style={{ width: 22, height: 22 }} />
<IconRobot size={22} />
) : (
<IconUser size={22} />
)}
Expand Down Expand Up @@ -219,13 +220,14 @@ export const ChatMessage: FC<Props> = memo(({ message, messageIndex, onEdit}) =>
const match = /language-(\w+)/.exec(className || '');
return !inline ? (
<CodeBlock
key={Math.random()}
//key={Math.random()}
key={messageIndex}
language={(match && match[1]) || ''}
value={String(children).replace(/\n$/, '')}
{...props}
/>
) : (
<code className={className} {...props}>
<code key={messageIndex} className={className} {...props}>
{children}
</code>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ const LoggingCard = ({ title, logString, tableData, logColor = 'black', imageDat
margin: 0,
},
}}>
<ReactMarkdown components={{ p: 'span' }} rehypePlugins={[rehypeRaw]}>
<ReactMarkdown components={{
p: ({ node, ...props }) => <span {...props} />
}}
rehypePlugins={[rehypeRaw as unknown as any]}>
{formattedLogString}
</ReactMarkdown>
</Typography>
Expand Down
12 changes: 12 additions & 0 deletions docker_utils/ehrapy/docker_start_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cd /app/
python3.10 -m src.deploy.inference_dialog_server &
backend_pid=$!

cd /app/chatbot_ui_biomania/
npm start &
frontend_pid=$!

# Keep the script running to keep the processes alive
wait $backend_pid
wait $frontend_pid

72 changes: 72 additions & 0 deletions docker_utils/ehrapy/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
astunparse==1.6.3
astor
beautifulsoup4==4.12.2
bionty==0.36.0
#biotite==0.38.0
#biopython==1.81
bitsandbytes==0.41.1
#cellrank==2.0.4
colorama
#deap==1.4.1
#deepspeed==0.12.0
docstring_parser==0.15
ehrapy==0.6.0
Flask==3.0.0
flask_cors==4.0.0
flask_socketio==5.3.6
#fpdf==1.7.2
gradio==3.14.0
#joblib==1.3.2
jsonargparse==4.27.0
langchain==0.0.330
#lightning==2.0.0
#lightning @ git+https://github.com/Lightning-AI/lightning@master
loguru
lxml==4.9.3
matplotlib
medcat==1.10.0
mmtf_python==1.1.3
nbformat==5.9.2
#networkx==3.2.1
numpy
ollama
openai==1.10.0
pandas
#peft==0.6.0
protobuf==3.20.0
pydantic==1.10.11
pydot==1.4.2
PyGithub==2.3.0
#pyopenms==3.1.0
#PyQt5
#pyteomics==4.6.3
python_dotenv
rank_bm25==0.2.2
rdflib==7.0.0
ReportLab
Requests
#scikit_bio==0.5.9
#scikit_learn
scipy==1.9.2
#scvi_tools==1.0.4
seaborn
sentence_transformers==2.2.2
sentencepiece==0.1.99
scanpy==1.9.6
#scikit-learn-intelex
scvelo==0.3.1
sphinx_rtd_theme
squidpy==1.3.1
tenacity==8.2.3
tensorboard==2.15.1
timm==0.9.12
torch==2.1.0
torchsummary==1.5.1
trimap==1.1.4
tqdm
transformers
typing_extensions==4.8.0
# triton
# scenicplus @ git+https://github.com/aertslab/scenicplus.git
# https://github.com/etetoolkit/ete/archive/ete4.zip

2 changes: 1 addition & 1 deletion docker_utils/scanpy/docker_start_script.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cd /app/
python3 -m src.deploy.inference_dialog_server &
python3.10 -m src.deploy.inference_dialog_server &
backend_pid=$!

cd /app/chatbot_ui_biomania/
Expand Down
Loading

0 comments on commit 4fa1d89

Please sign in to comment.