File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change 13
13
14
14
15
15
from schema import ErrorResponse , ModelDayInput , IntervalResponce , IntervalRequest
16
-
17
16
import pandas as pd
18
17
19
18
@@ -27,8 +26,8 @@ async def lifespan(app: FastAPI):
27
26
# Initialize the pytorch model
28
27
model = Model ()
29
28
30
- df = pd .read_csv ("./model_ser/pred.csv" )
31
- df ["date" ] = pd .to_datetime (df ["date" ])
29
+ df = pd .read_csv ("./app/ model_ser/pred.csv" )
30
+ df ["date" ] = pd .to_datetime (df ["date" ]). dt . date
32
31
# add model and other preprocess tools too app state
33
32
app .package = {"model" : model , "predict" : df }
34
33
yield
@@ -117,11 +116,8 @@ def bash(command):
117
116
@app .post ("/api/v1/predict_interval" )
118
117
def do_predict_interval (data : IntervalRequest ):
119
118
df = app .package ["predict" ]
120
- filter_df = df [
121
- df ["date" ]
122
- >= pd .to_datetime (data .left ) & df ["date" ]
123
- <= pd .to_datetime (data .right )
124
- ]
119
+ filter_df = df [(df ["date" ] >= data .left )]
120
+ filter_df = filter_df [(filter_df ["date" ] <= data .right )]
125
121
length = [i + 1 for i in range (len (filter_df ))]
126
122
127
123
return IntervalResponce (
You can’t perform that action at this time.
0 commit comments