@@ -161,7 +161,7 @@ async def update_service_run_last_heartbeat(
161161 row = result .first ()
162162 if row is None :
163163 return None
164- return ServiceRunDB .from_orm (row )
164+ return ServiceRunDB .model_validate (row )
165165
166166 async def update_service_run_stopped_at (
167167 self , data : ServiceRunStoppedAtUpdate
@@ -191,7 +191,7 @@ async def update_service_run_stopped_at(
191191 row = result .first ()
192192 if row is None :
193193 return None
194- return ServiceRunDB .from_orm (row )
194+ return ServiceRunDB .model_validate (row )
195195
196196 async def get_service_run_by_id (
197197 self , service_run_id : ServiceRunId
@@ -204,7 +204,7 @@ async def get_service_run_by_id(
204204 row = result .first ()
205205 if row is None :
206206 return None
207- return ServiceRunDB .from_orm (row )
207+ return ServiceRunDB .model_validate (row )
208208
209209 async def list_service_runs_by_product_and_user_and_wallet (
210210 self ,
@@ -309,7 +309,9 @@ async def list_service_runs_by_product_and_user_and_wallet(
309309
310310 result = await conn .execute (query )
311311
312- return [ServiceRunWithCreditsDB .from_orm (row ) for row in result .fetchall ()]
312+ return [
313+ ServiceRunWithCreditsDB .model_validate (row ) for row in result .fetchall ()
314+ ]
313315
314316 async def get_osparc_credits_aggregated_by_service (
315317 self ,
@@ -405,7 +407,7 @@ async def get_osparc_credits_aggregated_by_service(
405407 return (
406408 cast (int , count_result .scalar ()),
407409 [
408- OsparcCreditsAggregatedByServiceKeyDB .from_orm (row )
410+ OsparcCreditsAggregatedByServiceKeyDB .model_validate (row )
409411 for row in list_result .fetchall ()
410412 ],
411413 )
@@ -571,7 +573,7 @@ async def list_service_runs_with_running_status_across_all_products(
571573 )
572574 result = await conn .execute (query )
573575
574- return [ServiceRunForCheckDB .from_orm (row ) for row in result .fetchall ()]
576+ return [ServiceRunForCheckDB .model_validate (row ) for row in result .fetchall ()]
575577
576578 async def total_service_runs_with_running_status_across_all_products (
577579 self ,
@@ -620,7 +622,7 @@ async def update_service_missed_heartbeat_counter(
620622 row = result .first ()
621623 if row is None :
622624 return None
623- return ServiceRunDB .from_orm (row )
625+ return ServiceRunDB .model_validate (row )
624626
625627 #################################
626628 # Credit transactions
@@ -847,7 +849,7 @@ def _version(column_or_value):
847849 result = await conn .execute (query )
848850
849851 return [
850- PricingPlansWithServiceDefaultPlanDB .from_orm (row )
852+ PricingPlansWithServiceDefaultPlanDB .model_validate (row )
851853 for row in result .fetchall ()
852854 ]
853855
@@ -873,7 +875,7 @@ async def get_pricing_plan(
873875 raise CustomResourceUsageTrackerError (
874876 msg = f"Pricing plan does not exists: { pricing_plan_id } "
875877 )
876- return PricingPlansDB .from_orm (row )
878+ return PricingPlansDB .model_validate (row )
877879
878880 async def list_pricing_plans_by_product (
879881 self , product_name : ProductName
@@ -890,7 +892,7 @@ async def list_pricing_plans_by_product(
890892 ).where (resource_tracker_pricing_plans .c .product_name == product_name )
891893 result = await conn .execute (select_stmt )
892894
893- return [PricingPlansDB .from_orm (row ) for row in result .fetchall ()]
895+ return [PricingPlansDB .model_validate (row ) for row in result .fetchall ()]
894896
895897 async def create_pricing_plan (self , data : PricingPlanCreate ) -> PricingPlansDB :
896898 async with self .db_engine .begin () as conn :
@@ -924,7 +926,7 @@ async def create_pricing_plan(self, data: PricingPlanCreate) -> PricingPlansDB:
924926 raise CustomResourceUsageTrackerError (
925927 msg = f"Pricing plan was not created: { data } "
926928 )
927- return PricingPlansDB .from_orm (row )
929+ return PricingPlansDB .model_validate (row )
928930
929931 async def update_pricing_plan (
930932 self , product_name : ProductName , data : PricingPlanUpdate
@@ -961,7 +963,7 @@ async def update_pricing_plan(
961963 row = result .first ()
962964 if row is None :
963965 return None
964- return PricingPlansDB .from_orm (row )
966+ return PricingPlansDB .model_validate (row )
965967
966968 #################################
967969 # Pricing plan to service
@@ -1000,7 +1002,9 @@ async def list_connected_services_to_pricing_plan_by_pricing_plan(
10001002 )
10011003 result = await conn .execute (query )
10021004
1003- return [PricingPlanToServiceDB .from_orm (row ) for row in result .fetchall ()]
1005+ return [
1006+ PricingPlanToServiceDB .model_validate (row ) for row in result .fetchall ()
1007+ ]
10041008
10051009 async def upsert_service_to_pricing_plan (
10061010 self ,
@@ -1087,7 +1091,7 @@ async def upsert_service_to_pricing_plan(
10871091 raise CustomResourceUsageTrackerError (
10881092 msg = "Pricing plan to service record was not created"
10891093 )
1090- return PricingPlanToServiceDB .from_orm (row )
1094+ return PricingPlanToServiceDB .model_validate (row )
10911095
10921096 #################################
10931097 # Pricing units
@@ -1145,7 +1149,7 @@ async def list_pricing_units_by_pricing_plan(
11451149 )
11461150 result = await conn .execute (query )
11471151
1148- return [PricingUnitsDB .from_orm (row ) for row in result .fetchall ()]
1152+ return [PricingUnitsDB .model_validate (row ) for row in result .fetchall ()]
11491153
11501154 async def get_valid_pricing_unit (
11511155 self ,
@@ -1197,7 +1201,7 @@ async def get_valid_pricing_unit(
11971201 raise CustomResourceUsageTrackerError (
11981202 msg = f"Pricing plan { pricing_plan_id } and pricing unit { pricing_unit_id } for product { product_name } not found"
11991203 )
1200- return PricingUnitsDB .from_orm (row )
1204+ return PricingUnitsDB .model_validate (row )
12011205
12021206 async def create_pricing_unit_with_cost (
12031207 self , data : PricingUnitWithCostCreate , pricing_plan_key : str
@@ -1348,4 +1352,4 @@ async def get_pricing_unit_cost_by_id(
13481352 raise CustomResourceUsageTrackerError (
13491353 msg = f"Pricing unit cost id { pricing_unit_cost_id } not found in the resource_tracker_pricing_unit_costs table" ,
13501354 )
1351- return PricingUnitCostsDB .from_orm (row )
1355+ return PricingUnitCostsDB .model_validate (row )
0 commit comments