Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-limited resource values #136

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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