Skip to content

Commit

Permalink
Merge pull request #173 from ecmwf-projects/COPDS-1713-max-portal-costs
Browse files Browse the repository at this point in the history
Introduce kwargs in estimate_costs
  • Loading branch information
mcucchi9 authored Sep 16, 2024
2 parents 284357d + c3f4075 commit 67bc5b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions cads_adaptors/adaptors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,16 @@ def apply_constraints(self, request: Request) -> dict[str, Any]:
pass

@abc.abstractmethod
def estimate_costs(self, request: Request) -> dict[str, int]:
def estimate_costs(self, request: Request, **kwargs: Any) -> dict[str, int]:
"""
Estimate the costs associated with the request.
Parameters
----------
request : Request
Incoming request.
**kwargs : Any
Additional parameters, specific to the particular method's implementation.
Returns
-------
Expand Down Expand Up @@ -202,7 +204,7 @@ class DummyAdaptor(AbstractAdaptor):
def apply_constraints(self, request: Request) -> dict[str, Any]:
return {}

def estimate_costs(self, request: Request) -> dict[str, int]:
def estimate_costs(self, request: Request, **kwargs: Any) -> dict[str, int]:
size = int(request.get("size", 0))
time = int(request.get("time", 0.0))
return {"size": size, "time": time}
Expand Down
5 changes: 2 additions & 3 deletions cads_adaptors/adaptors/cds.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ def intersect_constraints(self, request: Request) -> list[Request]:
def apply_mapping(self, request: Request) -> Request:
return mapping.apply_mapping(request, self.mapping)

def estimate_costs(
self, request: Request, cost_threshold: str = "max_costs"
) -> dict[str, int]:
def estimate_costs(self, request: Request, **kwargs: Any) -> dict[str, int]:
cost_threshold = kwargs.get("cost_threshold", "max_costs")
costing_config: dict[str, Any] = self.config.get("costing", dict())
costing_kwargs: dict[str, Any] = costing_config.get("costing_kwargs", dict())
cost_threshold = (
Expand Down

0 comments on commit 67bc5b6

Please sign in to comment.