File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 runs-on : ubuntu-latest
1313 strategy :
1414 matrix :
15- python-version : [3.11]
15+ python-version : [3.11, 3.12, 3.13 ]
1616
1717 steps :
1818 - name : Checkout
Original file line number Diff line number Diff line change @@ -45,8 +45,9 @@ async def predict_caloric_needs(
4545 raise HTTPException (status_code = 500 , detail = "Model loader not initialized" )
4646
4747 try :
48- # Convert Pydantic model to dict
49- input_dict = input_data .dict ()
48+ # Convert Pydantic model to dict (use model_dump for Pydantic v2)
49+ # `model_dump` is the v2 replacement for `.dict()` and returns a dict.
50+ input_dict = input_data .model_dump ()
5051
5152 # Make prediction
5253 result = model_loader .predict (input_dict , model_preference = model )
@@ -89,7 +90,7 @@ async def batch_predict(
8990
9091 for input_data in batch_input .inputs :
9192 try :
92- input_dict = input_data .dict ()
93+ input_dict = input_data .model_dump ()
9394 result = model_loader .predict (input_dict , model_preference = model_pref )
9495 results .append (result )
9596
Original file line number Diff line number Diff line change 99from fastapi .testclient import TestClient
1010
1111
12- def make_dummy_model (pred_value = 123.45 , feature_names = None ):
13- class DummyModel :
14- def __init__ (self , v , cols = None ):
15- self ._v = v
16- if cols is not None :
17- # mimic scikit-learn attribute
18- self .feature_names_in_ = cols
12+ class DummyModel :
13+ def __init__ (self , v , cols = None ):
14+ self ._v = v
15+ if cols is not None :
16+ # mimic scikit-learn attribute
17+ self .feature_names_in_ = cols
18+
19+ def predict (self , X ):
20+ # return array-like
21+ return [self ._v ] * len (X )
1922
20- def predict (self , X ):
21- # return array-like
22- return [self ._v ] * len (X )
2323
24+ def make_dummy_model (pred_value = 123.45 , feature_names = None ):
2425 return DummyModel (pred_value , feature_names )
2526
2627
You can’t perform that action at this time.
0 commit comments