ShrirajSK commited on
Commit
0f0168e
·
1 Parent(s): 6a879e5

Upload 5 files

Browse files
Files changed (5) hide show
  1. docker-compose.yml +23 -0
  2. dockerfile +17 -0
  3. gradient_boosting.joblib +3 -0
  4. main.py +16 -0
  5. requirements.txt +5 -0
docker-compose.yml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: "3"
2
+
3
+
4
+
5
+ services:
6
+
7
+
8
+
9
+ app:
10
+
11
+ container_name: airflow_ml_model
12
+
13
+ build: .
14
+
15
+ command: bash -c "uvicorn main:app --host 0.0.0.0 --port 8000"
16
+ volumes:
17
+
18
+ - .:/app
19
+
20
+ ports:
21
+
22
+ - 8000:8000
23
+
dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ RUN pip install joblib
4
+ RUN pip install python-multipart
5
+
6
+ WORKDIR /app
7
+
8
+ COPY requirements.txt /app
9
+
10
+ # Upgrade pip and install Python packages
11
+ RUN pip3 install --upgrade pip && \
12
+ pip3 install --no-cache-dir -r requirements.txt
13
+
14
+ COPY . /app
15
+
16
+
17
+ EXPOSE 8000
gradient_boosting.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64632f01e67f085ec3944223d00aae47e64eb351a3699768e71a90078fe798b8
3
+ size 166972
main.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Response, status, File, Form, UploadFile
2
+ from pydantic import BaseModel
3
+ import joblib
4
+
5
+ class Airflow(BaseModel):
6
+ topic: str
7
+
8
+ app = FastAPI()
9
+
10
+ model = joblib.load("gradient_boosting.joblib")
11
+
12
+ @app.post("/api/volume_prediction")
13
+ async def predict_volume(vol_moving_avg: float = Form(), adj_close_rolling_med: float = Form()):
14
+ features = [vol_moving_avg, adj_close_rolling_med]
15
+ predicted_volume = model.predict([features])[0]
16
+ return {"predicted_volume": predicted_volume}
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ fastapi
2
+ uvicorn
3
+ scikit-learn
4
+ python-multipart
5
+ joblib