Skip to content

Commit

Permalink
Support non-limited resource values (logicalclocks#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
javierdlrm authored and robzor92 committed Aug 9, 2022
1 parent fa00312 commit 724ca6c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
25 changes: 17 additions & 8 deletions python/hsml/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,42 +185,51 @@ def _get_default_resource_limits(self):
def _validate_resources(self):
# limits
max_resources = client.get_serving_resource_limits()
if max_resources["cores"] > -1 and self._limits.cores > max_resources["cores"]:
if max_resources["cores"] > -1 and (
self._limits.cores < 0 or self._limits.cores > max_resources["cores"]
):
raise ValueError(
"Limit number of cores cannot exceed the maximum of "
+ str(max_resources["cores"])
+ " cores."
)
if (
max_resources["memory"] > -1
and self._limits.memory > max_resources["memory"]
if max_resources["memory"] > -1 and (
self._limits.memory < 0 or self._limits.memory > max_resources["memory"]
):
raise ValueError(
"Limit memory resources cannot exceed the maximum of "
+ str(max_resources["memory"])
+ " MB."
)
if max_resources["gpus"] > -1 and self._limits.gpus > max_resources["gpus"]:
if max_resources["gpus"] > -1 and (
self._limits.gpus < 0 or self._limits.gpus > max_resources["gpus"]
):
raise ValueError(
"Limit number of gpus cannot exceed the maximum of "
+ str(max_resources["gpus"])
+ " gpus."
)

# requests
if self._requests.cores > self._limits.cores:
if self._limits.cores > -1 and (
self._requests.cores < 0 or self._requests.cores > self._limits.cores
):
raise ValueError(
"Requested number of cores cannot exceed the limit of "
+ str(self._limits.cores)
+ " cores."
)
if self._requests.memory > self._limits.memory:
if self._limits.memory > -1 and (
self._requests.memory < 0 or self._requests.memory > self._limits.memory
):
raise ValueError(
"Requested memory resources cannot exceed the limit of "
+ str(self._limits.memory)
+ " MB."
)
if self._requests.gpus > self._limits.gpus:
if self._limits.gpus > -1 and (
self._requests.gpus < 0 or self._requests.gpus > self._limits.gpus
):
raise ValueError(
"Requested number of gpus cannot exceed the limit of "
+ str(self._limits.gpus)
Expand Down
2 changes: 1 addition & 1 deletion python/hsml/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _validate_resources(cls, resources):
and client.get_serving_num_instances_limits()[0] == 0
):
raise ValueError(
"Number of transformer instances must be 0 for KServe deployments to enable scale-to-zero capabilities"
"Scale-to-zero is required for KServe deployments in this cluster. Please, set the number of transformer instances to 0."
)
return resources

Expand Down

0 comments on commit 724ca6c

Please sign in to comment.