mirror of
https://github.com/hanzo-ml/katib.git
synced 2026-09-24 00:31:27 +00:00
* chore: add condition branch in requeue logic. Signed-off-by: Electronic-Waste <[email protected]> * chore: add ReportObservationLog in katib_manager_util.go. Signed-off-by: Electronic-Waste <[email protected]> * chore: add ReportTrialUnavailableMetrics func. Signed-off-by: Electronic-Waste <[email protected]> * chore: insert unavailable value into Katib DB. Signed-off-by: Electronic-Waste <[email protected]> * fix: fix lint error. Signed-off-by: Electronic-Waste <[email protected]> * fix: add nil condition judgement. Signed-off-by: Electronic-Waste <[email protected]> * fix: add nil condition judgement in trial_controller_util.go Signed-off-by: Electronic-Waste <[email protected]> * chore(trial): delete nil check of MC kind in the Trial controller. Signed-off-by: Electronic-Waste <[email protected]> * chore(trial): init MC in newFakeTrialBatchJob to avoid nil condition in trial reconcile loop. Signed-off-by: Electronic-Waste <[email protected]> * fix(trial): fix lint error. Signed-off-by: Electronic-Waste <[email protected]> * fix(trial): fix lint error in controller. Signed-off-by: Electronic-Waste <[email protected]> * test(trial): add integration test for Push MC. Signed-off-by: Electronic-Waste <[email protected]> * chore(trial): retry reconcilation when reporting unavailable metrics failed. Signed-off-by: Electronic-Waste <[email protected]> * test(trial): fix EXPECT order. Signed-off-by: Electronic-Waste <[email protected]> * test(trial): fix typo error. Signed-off-by: Electronic-Waste <[email protected]> * chore(trial): add errReportMetricsFailed. Signed-off-by: Electronic-Waste <[email protected]> * Update pkg/controller.v1beta1/trial/trial_controller.go Co-authored-by: Andrey Velichkevich <[email protected]> Signed-off-by: Electronic-Waste <[email protected]> * Update pkg/controller.v1beta1/trial/trial_controller_util.go Co-authored-by: Yuki Iwai <[email protected]> Signed-off-by: Electronic-Waste <[email protected]> * Update pkg/controller.v1beta1/trial/trial_controller.go Co-authored-by: Yuki Iwai <[email protected]> Signed-off-by: Electronic-Waste <[email protected]> * fix(trial): rename errors pkg. Signed-off-by: Electronic-Waste <[email protected]> * test(trial): update the order of UT. Signed-off-by: Electronic-Waste <[email protected]> * test(trial): use different names for UTs. Signed-off-by: Electronic-Waste <[email protected]> * test(trial): separate Push MC UTs with original UTs. Signed-off-by: Electronic-Waste <[email protected]> * test(trial): fix line error with gofmt. Signed-off-by: Electronic-Waste <[email protected]> * test(trial): reserve one UT for Push MC. Signed-off-by: Electronic-Waste <[email protected]> * test(trial): fix typo error. Signed-off-by: Electronic-Waste <[email protected]> * test(trial): make some tiny changes. Signed-off-by: Electronic-Waste <[email protected]> * fix(trial): move cancel func to t.Cleanup. Signed-off-by: Electronic-Waste <[email protected]> * fix(trial): use the propagated gomega instance to improve debuggability. Signed-off-by: Electronic-Waste <[email protected]> * fix(trial): use gofmt to reformat code. Signed-off-by: Electronic-Waste <[email protected]> --------- Signed-off-by: Electronic-Waste <[email protected]> Co-authored-by: Andrey Velichkevich <[email protected]> Co-authored-by: Yuki Iwai <[email protected]>
108 lines
3.3 KiB
Go
108 lines
3.3 KiB
Go
/*
|
|
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.
|
|
*/
|
|
|
|
package managerclient
|
|
|
|
import (
|
|
trialsv1beta1 "github.com/kubeflow/katib/pkg/apis/controller/trials/v1beta1"
|
|
api_pb "github.com/kubeflow/katib/pkg/apis/manager/v1beta1"
|
|
common "github.com/kubeflow/katib/pkg/common/v1beta1"
|
|
)
|
|
|
|
// ManagerClient is the interface for katib manager client in trial controller.
|
|
type ManagerClient interface {
|
|
GetTrialObservationLog(
|
|
instance *trialsv1beta1.Trial) (*api_pb.GetObservationLogReply, error)
|
|
DeleteTrialObservationLog(
|
|
instance *trialsv1beta1.Trial) (*api_pb.DeleteObservationLogReply, error)
|
|
ReportTrialObservationLog(
|
|
instance *trialsv1beta1.Trial,
|
|
observationLogs *api_pb.ObservationLog) (*api_pb.ReportObservationLogReply, error)
|
|
}
|
|
|
|
// DefaultClient implements the Client interface.
|
|
type DefaultClient struct {
|
|
}
|
|
|
|
// New creates a new ManagerClient.
|
|
func New() ManagerClient {
|
|
return &DefaultClient{}
|
|
}
|
|
|
|
func (d *DefaultClient) GetTrialObservationLog(
|
|
instance *trialsv1beta1.Trial) (*api_pb.GetObservationLogReply, error) {
|
|
// read GetObservationLog call and update observation field
|
|
objectiveMetricName := instance.Spec.Objective.ObjectiveMetricName
|
|
request := &api_pb.GetObservationLogRequest{
|
|
TrialName: instance.Name,
|
|
MetricName: objectiveMetricName,
|
|
}
|
|
reply, err := common.GetObservationLog(request)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if reply.ObservationLog == nil {
|
|
reply.ObservationLog = &api_pb.ObservationLog{}
|
|
}
|
|
if reply.ObservationLog.MetricLogs == nil {
|
|
reply.ObservationLog.MetricLogs = []*api_pb.MetricLog{}
|
|
}
|
|
// fetch additional metrics if exists
|
|
metricLogs := reply.ObservationLog.MetricLogs
|
|
for _, metricName := range instance.Spec.Objective.AdditionalMetricNames {
|
|
request := &api_pb.GetObservationLogRequest{
|
|
TrialName: instance.Name, MetricName: metricName,
|
|
}
|
|
reply, err := common.GetObservationLog(request)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if reply.ObservationLog == nil || reply.ObservationLog.MetricLogs == nil {
|
|
continue
|
|
}
|
|
metricLogs = append(metricLogs, reply.ObservationLog.MetricLogs...)
|
|
}
|
|
reply.ObservationLog.MetricLogs = metricLogs
|
|
|
|
return reply, nil
|
|
}
|
|
|
|
func (d *DefaultClient) DeleteTrialObservationLog(
|
|
instance *trialsv1beta1.Trial) (*api_pb.DeleteObservationLogReply, error) {
|
|
request := &api_pb.DeleteObservationLogRequest{
|
|
TrialName: instance.Name,
|
|
}
|
|
reply, err := common.DeleteObservationLog(request)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return reply, nil
|
|
}
|
|
|
|
func (d *DefaultClient) ReportTrialObservationLog(
|
|
instance *trialsv1beta1.Trial,
|
|
observationLog *api_pb.ObservationLog) (*api_pb.ReportObservationLogReply, error) {
|
|
request := &api_pb.ReportObservationLogRequest{
|
|
TrialName: instance.Name,
|
|
ObservationLog: observationLog,
|
|
}
|
|
reply, err := common.ReportObservationLog(request)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return reply, nil
|
|
}
|