Skip to content

Commit 5a64d72

Browse files
authored
Merge pull request #245 from ecmwf-projects/feature/costing-classes
Allow str fields in the costing (for costing classes)
2 parents b3b9881 + 3982f1f commit 5a64d72

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cads_processing_api_service/costing.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,20 @@ def compute_costing(
181181
if request_origin not in COST_THRESHOLDS:
182182
raise ValueError(f"Invalid request origin: {request_origin}")
183183
cost_threshold = COST_THRESHOLDS[request_origin]
184-
costs: dict[str, float] = adaptor.estimate_costs(
184+
costs: dict[str, Any] = adaptor.estimate_costs(
185185
request=request, cost_threshold=cost_threshold
186186
)
187+
costs_numeric = {
188+
cost_id: cost
189+
for cost_id, cost in costs.items()
190+
if isinstance(cost, (int, float))
191+
}
187192
costing_config: dict[str, Any] = adaptor_properties["config"].get("costing", {})
188193
limits: dict[str, Any] = costing_config.get("max_costs", {})
189194
cost_bar_steps = (
190195
costing_config.get("cost_bar_steps", None) if request_origin == "ui" else None
191196
)
192197
costing_info = models.CostingInfo(
193-
costs=costs, limits=limits, cost_bar_steps=cost_bar_steps
198+
costs=costs_numeric, limits=limits, cost_bar_steps=cost_bar_steps
194199
)
195200
return costing_info

0 commit comments

Comments
 (0)