Skip to content

Commit

Permalink
dockerized the application and fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Raghav010 committed Nov 8, 2023
1 parent f32bed6 commit b7b2d0a
Show file tree
Hide file tree
Showing 14 changed files with 583 additions and 315 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
medmini.pdf
README.md
media/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
med_db/

3 changes: 2 additions & 1 deletion App/TextInputComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const TextInputComponent = () => {
const handleTextSubmit = async () => {
try {
console.log(myRAM, text);
const url = "http://10.2.133.59:5000/query";
const url = "http://"+String(process.env.EXPO_PUBLIC_HOSTIP)+":5000/query";
console.log(url)
const headers = {
'Content-Type': 'application/json',
};
Expand Down
398 changes: 398 additions & 0 deletions App/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions App/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.72.6",
"react-native-animated-ellipsis": "^2.0.0",
"react-native-device-info": "^10.11.0"
},
"devDependencies": {
Expand Down
44 changes: 32 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
FROM alpine:3.14
FROM node:18-bookworm-slim

RUN sudo apt install conda
RUN conda env create -f ./build_utils/env.yml
# ARG REACT_NATIVE_PACKAGER_HOSTNAME

COPY ./App
COPY ./backend.py
COPY ./dbGen.py
COPY ./medmini.py
COPY ./mashqa_data
COPY ./build_utils/run.sh
WORKDIR /medmini
COPY . .

RUN conda activate medmini

RUN chmod +x run.sh
RUN run.sh

RUN mv build_utils/services.sh services.sh \
&& chmod +x services.sh \
&& apt-get update \
# && apt install curl -y \
&& cd App && npm ci && cd .. \
&& apt-get update \
&& apt-get install python3 python3-pip -y \
&& rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED \
&& pip3 install torch==2.1.0 --index-url https://download.pytorch.org/whl/cpu \
&& pip3 install transformers==4.34.1 langchain==0.0.324 Flask==3.0.0 flask-cors==4.0.0 chromadb==0.4.15 sentence-transformers==2.2.2 sentencepiece==0.1.99

# SHELL ["/bin/bash", "--login", "-i", "-c"]
# SHELL ["/bin/bash", "--login", "-c"]




# EXPOSE 19000 19001 19002
EXPOSE 8081 5000


CMD ./services.sh



# todo
# use a smaller base image
12 changes: 8 additions & 4 deletions backend.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from flask import Flask, request;
from flask_cors import CORS, cross_origin
# from pegasus import pegasus;\
from medmini import infer
from medmini import infer,systemInit

app = Flask(__name__)
CORS(app)
summarizer=None
vectordb=None

@app.route('/', methods=['GET', 'POST'])
@cross_origin(supports_credentials=True)
Expand All @@ -18,7 +19,10 @@ def root():
def x():
# print(request.get_json(force=True)["question"])
# return request.get_json(force=True)["text"]
return infer(request.get_json(force=True)["question"])
global summarizer
global vectordb
return infer(request.get_json(force=True)["question"],summarizer,vectordb)

if __name__ == '__main__':
app.run(host='192.168.196.219', port=5000, debug=True)
summarizer,vectordb=systemInit()
app.run(host="0.0.0.0",port=5000,debug=True)
209 changes: 0 additions & 209 deletions build_utils/env.yml

This file was deleted.

8 changes: 8 additions & 0 deletions build_utils/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
transformers
langchain
Flask
flask-cors
chromadb
sentence-transformers
sentencepiece
torch --index-url https://download.pytorch.org/whl/cpu
9 changes: 0 additions & 9 deletions build_utils/run.sh

This file was deleted.

12 changes: 12 additions & 0 deletions build_utils/services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash




python3 backend.py &
cd App/ ; echo EXPO_PUBLIC_HOSTIP=$REACT_NATIVE_PACKAGER_HOSTNAME > .env
npx expo start &

wait -n

exit $?
28 changes: 28 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# updating repositories and installing curl
apt update
apt install curl -y

# installing node and npm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
source ~/.bashrc
nvm install v18.13.0


# installing all node modules required
cd App
npm ci
cd ..


# setting up python deps
apt update
apt install python3.10 python3-pip -y
pip3 install torch --index-url https://download.pytorch.org/whl/cpu
pip3 install transformers langchain Flask flask-cors chromadb sentence-transformers sentencepiece


#todo
# pull the med_db

Loading

0 comments on commit b7b2d0a

Please sign in to comment.