Skip to content

Commit

Permalink
Feature/costing with mapped requests (#227)
Browse files Browse the repository at this point in the history
* costing with mapped request

* handle unknowned widgets
  • Loading branch information
EddyCMWF authored Oct 14, 2024
1 parent c9f47e5 commit fbd531a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cads_adaptors/adaptors/cds.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ def estimate_costs(self, request: Request, **kwargs: Any) -> dict[str, int]:
# Safety net, not all stacks have the latest version of the api:
if "inputs" in request:
request = request["inputs"]
mapped_request = self.apply_mapping(request)

# "precise_size" is a new costing method that is more accurate than "size
if "precise_size" in costing_config.get(cost_threshold, {}):
costs["precise_size"] = costing.estimate_precise_size(
self.form,
request,
mapped_request,
self.constraints,
**costing_kwargs,
)
# size is a fast and rough estimate of the number of fields
costs["size"] = costing.estimate_number_of_fields(self.form, request)
costs["size"] = costing.estimate_number_of_fields(self.form, mapped_request)
# Safety net for integration tests:
costs["number_of_fields"] = costs["size"]
return costs
Expand Down
1 change: 0 additions & 1 deletion cads_adaptors/costing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

EXCLUDED_WIDGETS = [
"GeographicExtentWidget",
"UnknownWidget",
]

# TODO: Handle DateRangeWidget
Expand Down

0 comments on commit fbd531a

Please sign in to comment.