We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3f80b1c commit 9cbb027Copy full SHA for 9cbb027
src/make_api/app/main.py
@@ -17,8 +17,6 @@ def get_model(model_uri):
17
return mlflow.sklearn.load_model(model_uri)
18
19
20
-pipe = get_model(model_uri)
21
-
22
app = FastAPI()
23
24
@@ -41,7 +39,7 @@ async def read_root():
41
39
async def predict_one(data: InferenceInput) -> dict[str, float]:
42
40
try:
43
df_input = pd.DataFrame([data.dict()]) # pd df might be overkill
44
- prediction = pipe.predict(df_input)
+ prediction = get_model(model_uri).predict(df_input)
45
return {"prediction": prediction[0]}
46
except Exception as e:
47
raise HTTPException(status_code=400, detail=f"Prediction failed: {str(e)}") from e
0 commit comments