Skip to content

Commit

Permalink
add cost_bar_steps to RequestCost
Browse files Browse the repository at this point in the history
  • Loading branch information
mcucchi9 committed Sep 17, 2024
1 parent 4f41fb7 commit 79978cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cads_processing_api_service/costing.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def estimate_cost(
request.get("inputs", {}), adaptor_properties, request_origin
)
cost = costing.compute_highest_cost_limit_ratio(costing_info)
if costing_info.cost_bar_steps:
cost.cost_bar_steps = costing_info.cost_bar_steps
return cost


Expand Down Expand Up @@ -128,5 +130,8 @@ def compute_costing(
)
costing_config: dict[str, Any] = adaptor_properties["config"].get("costing", {})
limits: dict[str, Any] = costing_config.get("max_costs", {})
costing_info = models.CostingInfo(costs=costs, limits=limits)
cost_bar_steps = costing_config.get("cost_bar_steps", None)
costing_info = models.CostingInfo(
costs=costs, limits=limits, cost_bar_steps=cost_bar_steps
)
return costing_info
2 changes: 2 additions & 0 deletions cads_processing_api_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ class Exception(ogc_api_processes_fastapi.models.Exception):
class CostingInfo(pydantic.BaseModel):
costs: dict[str, float] = {}
limits: dict[str, float] = {}
cost_bar_steps: list[int] | None = None


class RequestCost(pydantic.BaseModel):
id: str | None = None
cost: float = 0.0
limit: float = 1.0
cost_bar_steps: list[int] | None = None


class Execute(ogc_api_processes_fastapi.models.Execute):
Expand Down

0 comments on commit 79978cb

Please sign in to comment.