-
Notifications
You must be signed in to change notification settings - Fork 485
Implement validations for darts suggestion service #1926
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
google-oss-prow
merged 9 commits into
kubeflow:master
from
tenzen-y:implement-darts-validation-algorithm
Aug 18, 2022
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
44dead9
implement validation for darts service
tenzen-y b3fb220
Update pkg/suggestion/v1beta1/nas/darts/service.py
tenzen-y 7ed1f08
Update pkg/suggestion/v1beta1/nas/darts/service.py
tenzen-y 2af1307
[review] delete todo comment
tenzen-y 9c6efdf
[review] change function name validate_algorithm_settings to validate…
tenzen-y 5d083e0
[review] fix vaiolation comments
tenzen-y 165592c
[review] fix condition to validate batch_size
tenzen-y 5b190a4
[review] add comment for developers
tenzen-y d338dd2
[review] use set instead of list
tenzen-y File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright 2022 The Kubeflow Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from pkg.apis.manager.v1beta1.python import api_pb2 | ||
|
||
|
||
def validate_operations(operations: list[api_pb2.Operation]) -> (bool, str): | ||
|
||
# Validate each operation | ||
for operation in operations: | ||
|
||
# Check OperationType | ||
if not operation.operation_type: | ||
return False, "Missing operationType in Operation:\n{}".format(operation) | ||
|
||
# Check ParameterConfigs | ||
if not operation.parameter_specs.parameters: | ||
return False, "Missing ParameterConfigs in Operation:\n{}".format(operation) | ||
|
||
# Validate each ParameterConfig in Operation | ||
parameters_list = list(operation.parameter_specs.parameters) | ||
for parameter in parameters_list: | ||
|
||
# Check Name | ||
if not parameter.name: | ||
return False, "Missing Name in ParameterConfig:\n{}".format(parameter) | ||
|
||
# Check ParameterType | ||
if not parameter.parameter_type: | ||
return False, "Missing ParameterType in ParameterConfig:\n{}".format(parameter) | ||
|
||
# Check List in Categorical or Discrete Type | ||
if parameter.parameter_type == api_pb2.CATEGORICAL or parameter.parameter_type == api_pb2.DISCRETE: | ||
if not parameter.feasible_space.list: | ||
return False, "Missing List in ParameterConfig.feasibleSpace:\n{}".format(parameter) | ||
|
||
# Check Max, Min, Step in Int or Double Type | ||
elif parameter.parameter_type == api_pb2.INT or parameter.parameter_type == api_pb2.DOUBLE: | ||
if not parameter.feasible_space.min and not parameter.feasible_space.max: | ||
return False, "Missing Max and Min in ParameterConfig.feasibleSpace:\n{}".format(parameter) | ||
|
||
try: | ||
if (parameter.parameter_type == api_pb2.DOUBLE and | ||
(not parameter.feasible_space.step or float(parameter.feasible_space.step) <= 0)): | ||
return False, \ | ||
"Step parameter should be > 0 in ParameterConfig.feasibleSpace:\n{}".format(parameter) | ||
except Exception as e: | ||
return False, \ | ||
"failed to validate ParameterConfig.feasibleSpace \n{parameter}):\n{exception}".format( | ||
parameter=parameter, exception=e) | ||
|
||
return True, "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.