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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing omitempty parameter to APIs #1645

Merged
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
4 changes: 2 additions & 2 deletions pkg/apis/controller/common/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ type Metric struct {
// +k8s:deepcopy-gen=true
type Observation struct {
// Key-value pairs for metric names and values
Metrics []Metric `json:"metrics"`
Metrics []Metric `json:"metrics,omitempty"`
}

// +k8s:deepcopy-gen=true
Expand Down Expand Up @@ -220,7 +220,7 @@ const (

// +k8s:deepcopy-gen=true
type CollectorSpec struct {
Kind CollectorKind `json:"kind"`
Kind CollectorKind `json:"kind,omitempty"`
// When kind is "customCollector", this field will be used
CustomCollector *v1.Container `json:"customCollector,omitempty"`
}
4 changes: 2 additions & 2 deletions pkg/apis/controller/experiments/v1beta1/experiment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ type ExperimentStatus struct {
// OptimalTrial is the metrics and assignments of the best trial.
type OptimalTrial struct {
// BestTrialName is the name of the best trial.
BestTrialName string `json:"bestTrialName"`
BestTrialName string `json:"bestTrialName,omitempty"`
// Key-value pairs for hyperparameters and assignment values.
ParameterAssignments []common.ParameterAssignment `json:"parameterAssignments"`
ParameterAssignments []common.ParameterAssignment `json:"parameterAssignments,omitempty"`

// Observation for this trial
Observation common.Observation `json:"observation,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
// SuggestionSpec is the specification of a Suggestion.
type SuggestionSpec struct {
// Algorithm describes HP or NAS algorithm that suggestion is used.
Algorithm *common.AlgorithmSpec `json:"algorithm"`
Algorithm *common.AlgorithmSpec `json:"algorithm,omitempty"`

// EarlyStopping describes early stopping algorithm that suggestion is used.
EarlyStopping *common.EarlyStoppingSpec `json:"earlyStopping,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/controller/trials/v1beta1/trial_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type TrialSpec struct {
Objective *common.ObjectiveSpec `json:"objective,omitempty"`

// Key-value pairs for hyperparameters and assignment values.
ParameterAssignments []common.ParameterAssignment `json:"parameterAssignments"`
ParameterAssignments []common.ParameterAssignment `json:"parameterAssignments,omitempty"`

// Rules for early stopping techniques.
// Each rule should be met to early stop Trial.
Expand Down
11 changes: 2 additions & 9 deletions pkg/apis/v1beta1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 2 additions & 20 deletions pkg/apis/v1beta1/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@
".v1beta1.SuggestionSpec": {
"description": "SuggestionSpec is the specification of a Suggestion.",
"type": "object",
"required": [
"algorithm"
],
"properties": {
"algorithm": {
"description": "Algorithm describes HP or NAS algorithm that suggestion is used.",
Expand Down Expand Up @@ -293,9 +290,6 @@
".v1beta1.TrialSpec": {
"description": "TrialSpec is the specification of a Trial.",
"type": "object",
"required": [
"parameterAssignments"
],
"properties": {
"earlyStoppingRules": {
"description": "Rules for early stopping techniques. Each rule should be met to early stop Trial.",
Expand Down Expand Up @@ -416,17 +410,13 @@
},
"v1beta1.CollectorSpec": {
"type": "object",
"required": [
"kind"
],
"properties": {
"customCollector": {
"description": "When kind is \"customCollector\", this field will be used",
"$ref": "#/definitions/v1.Container"
},
"kind": {
"type": "string",
"default": ""
"type": "string"
}
}
},
Expand Down Expand Up @@ -929,9 +919,6 @@
},
"v1beta1.Observation": {
"type": "object",
"required": [
"metrics"
],
"properties": {
"metrics": {
"description": "Key-value pairs for metric names and values",
Expand Down Expand Up @@ -962,15 +949,10 @@
"v1beta1.OptimalTrial": {
"description": "OptimalTrial is the metrics and assignments of the best trial.",
"type": "object",
"required": [
"bestTrialName",
"parameterAssignments"
],
"properties": {
"bestTrialName": {
"description": "BestTrialName is the name of the best trial.",
"type": "string",
"default": ""
"type": "string"
},
"observation": {
"description": "Observation for this trial",
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/v1beta1/docs/V1beta1CollectorSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**custom_collector** | [**V1Container**](https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1Container.md) | | [optional]
**kind** | **str** | | [default to '']
**kind** | **str** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
2 changes: 1 addition & 1 deletion sdk/python/v1beta1/docs/V1beta1Observation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**metrics** | [**list[V1beta1Metric]**](V1beta1Metric.md) | Key-value pairs for metric names and values |
**metrics** | [**list[V1beta1Metric]**](V1beta1Metric.md) | Key-value pairs for metric names and values | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
4 changes: 2 additions & 2 deletions sdk/python/v1beta1/docs/V1beta1OptimalTrial.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ OptimalTrial is the metrics and assignments of the best trial.
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**best_trial_name** | **str** | BestTrialName is the name of the best trial. | [default to '']
**best_trial_name** | **str** | BestTrialName is the name of the best trial. | [optional]
**observation** | [**V1beta1Observation**](V1beta1Observation.md) | | [optional]
**parameter_assignments** | [**list[V1beta1ParameterAssignment]**](V1beta1ParameterAssignment.md) | Key-value pairs for hyperparameters and assignment values. |
**parameter_assignments** | [**list[V1beta1ParameterAssignment]**](V1beta1ParameterAssignment.md) | Key-value pairs for hyperparameters and assignment values. | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
2 changes: 1 addition & 1 deletion sdk/python/v1beta1/docs/V1beta1SuggestionSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SuggestionSpec is the specification of a Suggestion.
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**algorithm** | [**V1beta1AlgorithmSpec**](V1beta1AlgorithmSpec.md) | |
**algorithm** | [**V1beta1AlgorithmSpec**](V1beta1AlgorithmSpec.md) | | [optional]
**early_stopping** | [**V1beta1EarlyStoppingSpec**](V1beta1EarlyStoppingSpec.md) | | [optional]
**requests** | **int** | Number of suggestions requested. | [optional]
**resume_policy** | **str** | ResumePolicy describes resuming policy which usually take effect after experiment terminated. Default value is LongRunning. | [optional]
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/v1beta1/docs/V1beta1TrialSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Name | Type | Description | Notes
**failure_condition** | **str** | Condition when trial custom resource is failed. Condition must be in GJSON format, ref https://github.com/tidwall/gjson. For example for BatchJob: status.conditions.#(type==\"Failed\")#|#(status==\"True\")# | [optional]
**metrics_collector** | [**V1beta1MetricsCollectorSpec**](V1beta1MetricsCollectorSpec.md) | | [optional]
**objective** | [**V1beta1ObjectiveSpec**](V1beta1ObjectiveSpec.md) | | [optional]
**parameter_assignments** | [**list[V1beta1ParameterAssignment]**](V1beta1ParameterAssignment.md) | Key-value pairs for hyperparameters and assignment values. |
**parameter_assignments** | [**list[V1beta1ParameterAssignment]**](V1beta1ParameterAssignment.md) | Key-value pairs for hyperparameters and assignment values. | [optional]
**primary_container_name** | **str** | Name of training container where actual model training is running | [optional]
**primary_pod_labels** | **dict(str, str)** | Label that determines if pod needs to be injected by Katib sidecar container | [optional]
**retain_run** | **bool** | Whether to retain the trial run object after completed. | [optional]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class V1beta1CollectorSpec(object):
'kind': 'kind'
}

def __init__(self, custom_collector=None, kind='', local_vars_configuration=None): # noqa: E501
def __init__(self, custom_collector=None, kind=None, local_vars_configuration=None): # noqa: E501
"""V1beta1CollectorSpec - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
Expand All @@ -54,7 +54,8 @@ def __init__(self, custom_collector=None, kind='', local_vars_configuration=None

if custom_collector is not None:
self.custom_collector = custom_collector
self.kind = kind
if kind is not None:
self.kind = kind

@property
def custom_collector(self):
Expand Down Expand Up @@ -95,8 +96,6 @@ def kind(self, kind):
:param kind: The kind of this V1beta1CollectorSpec. # noqa: E501
:type: str
"""
if self.local_vars_configuration.client_side_validation and kind is None: # noqa: E501
raise ValueError("Invalid value for `kind`, must not be `None`") # noqa: E501

self._kind = kind

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def __init__(self, metrics=None, local_vars_configuration=None): # noqa: E501
self._metrics = None
self.discriminator = None

self.metrics = metrics
if metrics is not None:
self.metrics = metrics

@property
def metrics(self):
Expand All @@ -71,8 +72,6 @@ def metrics(self, metrics):
:param metrics: The metrics of this V1beta1Observation. # noqa: E501
:type: list[V1beta1Metric]
"""
if self.local_vars_configuration.client_side_validation and metrics is None: # noqa: E501
raise ValueError("Invalid value for `metrics`, must not be `None`") # noqa: E501

self._metrics = metrics

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class V1beta1OptimalTrial(object):
'parameter_assignments': 'parameterAssignments'
}

def __init__(self, best_trial_name='', observation=None, parameter_assignments=None, local_vars_configuration=None): # noqa: E501
def __init__(self, best_trial_name=None, observation=None, parameter_assignments=None, local_vars_configuration=None): # noqa: E501
"""V1beta1OptimalTrial - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
Expand All @@ -55,10 +55,12 @@ def __init__(self, best_trial_name='', observation=None, parameter_assignments=N
self._parameter_assignments = None
self.discriminator = None

self.best_trial_name = best_trial_name
if best_trial_name is not None:
self.best_trial_name = best_trial_name
if observation is not None:
self.observation = observation
self.parameter_assignments = parameter_assignments
if parameter_assignments is not None:
self.parameter_assignments = parameter_assignments

@property
def best_trial_name(self):
Expand All @@ -80,8 +82,6 @@ def best_trial_name(self, best_trial_name):
:param best_trial_name: The best_trial_name of this V1beta1OptimalTrial. # noqa: E501
:type: str
"""
if self.local_vars_configuration.client_side_validation and best_trial_name is None: # noqa: E501
raise ValueError("Invalid value for `best_trial_name`, must not be `None`") # noqa: E501

self._best_trial_name = best_trial_name

Expand Down Expand Up @@ -126,8 +126,6 @@ def parameter_assignments(self, parameter_assignments):
:param parameter_assignments: The parameter_assignments of this V1beta1OptimalTrial. # noqa: E501
:type: list[V1beta1ParameterAssignment]
"""
if self.local_vars_configuration.client_side_validation and parameter_assignments is None: # noqa: E501
raise ValueError("Invalid value for `parameter_assignments`, must not be `None`") # noqa: E501

self._parameter_assignments = parameter_assignments

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def __init__(self, algorithm=None, early_stopping=None, requests=None, resume_po
self._resume_policy = None
self.discriminator = None

self.algorithm = algorithm
if algorithm is not None:
self.algorithm = algorithm
if early_stopping is not None:
self.early_stopping = early_stopping
if requests is not None:
Expand All @@ -84,8 +85,6 @@ def algorithm(self, algorithm):
:param algorithm: The algorithm of this V1beta1SuggestionSpec. # noqa: E501
:type: V1beta1AlgorithmSpec
"""
if self.local_vars_configuration.client_side_validation and algorithm is None: # noqa: E501
raise ValueError("Invalid value for `algorithm`, must not be `None`") # noqa: E501

self._algorithm = algorithm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def __init__(self, early_stopping_rules=None, failure_condition=None, metrics_co
self.metrics_collector = metrics_collector
if objective is not None:
self.objective = objective
self.parameter_assignments = parameter_assignments
if parameter_assignments is not None:
self.parameter_assignments = parameter_assignments
if primary_container_name is not None:
self.primary_container_name = primary_container_name
if primary_pod_labels is not None:
Expand Down Expand Up @@ -204,8 +205,6 @@ def parameter_assignments(self, parameter_assignments):
:param parameter_assignments: The parameter_assignments of this V1beta1TrialSpec. # noqa: E501
:type: list[V1beta1ParameterAssignment]
"""
if self.local_vars_configuration.client_side_validation and parameter_assignments is None: # noqa: E501
raise ValueError("Invalid value for `parameter_assignments`, must not be `None`") # noqa: E501

self._parameter_assignments = parameter_assignments

Expand Down