Skip to content

Commit

Permalink
fix auto deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan committed Apr 12, 2024
1 parent 4b89ef6 commit ee7b5b7
Show file tree
Hide file tree
Showing 6 changed files with 2,623 additions and 12 deletions.
8 changes: 3 additions & 5 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from contextlib import asynccontextmanager

import uvicorn
from fastapi import FastAPI, Request
from fastapi import FastAPI
from fastapi.logger import logger
from fastapi.middleware.cors import CORSMiddleware
from tests import api_test
Expand All @@ -13,9 +13,6 @@


from schema import (
InferenceResponse,
InferenceInput,
InferenceOutput,
ErrorResponse,
ModelDayInput,
)
Expand Down Expand Up @@ -157,8 +154,9 @@ def do_predict_day(data: ModelDayInput):
"""
from random import uniform

y = predict(app.package, data)
logger.info("API predict called")
return {"data": uniform(1.0, 100.0)}
return {"data": uniform(1.0, 100.0), "moex": y}


if __name__ == "__main__":
Expand Down
42 changes: 36 additions & 6 deletions app/model.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
import joblib
from schema import ModelDayInput
import pandas as pd


class Model:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def __init__(self):
self.moex_preprocess = joblib.load("./model_ser/moex_pipeline.plk")

def forward(self, data: ModelDayInput):
moex_df = pd.DataFrame(
{
"CAPITALIZATION": [data.CAPITALIZATION] * 2,
"CLOSE": [data.CAPITALIZATION] * 2,
"DIVISOR": [data.CAPITALIZATION] * 2,
"HIGH": [data.CAPITALIZATION] * 2,
"LOW": [data.CAPITALIZATION] * 2,
"OPEN": [data.CAPITALIZATION] * 2,
"TRADEDATE": [str(data.TRADEDATE)] * 2,
"NAME": [None] * 2,
"SHORTNAME": [None] * 2,
"SECID": [None] * 2,
"BOARDID": [None] * 2,
"DURATION": [None] * 2,
"YIELD": [None] * 2,
"DECIMALS": [None] * 2,
"CURRENCYID": [None] * 2,
"VOLUME": [None] * 2,
"TRADINGSESSION": [None] * 2,
"VALUE": [None] * 2,
}
)

moex_df = self.moex_preprocess.transform(moex_df)

def forward(self, *args, **kwargs):
return [42.0, 1, 2, 3]
return moex_df.to_dict()

def __call__(self, *args, **kwargs):
return self.forward(*args, **kwargs)
def __call__(self, data: ModelDayInput):
return self.forward(data)
Loading

0 comments on commit ee7b5b7

Please sign in to comment.