@@ -143,11 +143,16 @@ def compute_highest_cost_limit_ratio(
143
143
Info on the cost with the highest cost/limit ratio.
144
144
"""
145
145
costs = costing_info .costs
146
+ costs_numeric = {
147
+ cost_id : cost
148
+ for cost_id , cost in costs .items ()
149
+ if isinstance (cost , (int , float ))
150
+ }
146
151
limits = costing_info .limits
147
152
highest_cost_limit_ratio = 0.0
148
153
highest_cost = models .RequestCost ()
149
154
for limit_id , limit in limits .items ():
150
- cost = costs .get (limit_id , 0.0 )
155
+ cost = costs_numeric .get (limit_id , 0.0 )
151
156
cost_limit_ratio = cost / limit if limit > 0 else 1.1
152
157
if cost_limit_ratio > highest_cost_limit_ratio :
153
158
highest_cost_limit_ratio = cost_limit_ratio
@@ -184,17 +189,12 @@ def compute_costing(
184
189
costs : dict [str , Any ] = adaptor .estimate_costs (
185
190
request = request , cost_threshold = cost_threshold
186
191
)
187
- costs_numeric = {
188
- cost_id : cost
189
- for cost_id , cost in costs .items ()
190
- if isinstance (cost , (int , float ))
191
- }
192
192
costing_config : dict [str , Any ] = adaptor_properties ["config" ].get ("costing" , {})
193
193
limits : dict [str , Any ] = costing_config .get ("max_costs" , {})
194
194
cost_bar_steps = (
195
195
costing_config .get ("cost_bar_steps" , None ) if request_origin == "ui" else None
196
196
)
197
197
costing_info = models .CostingInfo (
198
- costs = costs_numeric , limits = limits , cost_bar_steps = cost_bar_steps
198
+ costs = costs , limits = limits , cost_bar_steps = cost_bar_steps
199
199
)
200
200
return costing_info
0 commit comments