From ad00f92e9a8cdf80116baddbb4f3259a1b3ca8b1 Mon Sep 17 00:00:00 2001 From: tzwang Date: Tue, 1 Jul 2025 15:02:21 +0800 Subject: [PATCH] update OctopusHttp --- internal/storeLink/octopusHttp/octopusHttp.go | 102 +++++++++--------- 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/internal/storeLink/octopusHttp/octopusHttp.go b/internal/storeLink/octopusHttp/octopusHttp.go index 23235c91..b9511f3f 100644 --- a/internal/storeLink/octopusHttp/octopusHttp.go +++ b/internal/storeLink/octopusHttp/octopusHttp.go @@ -123,47 +123,49 @@ func (o *OctopusHttp) Execute(ctx context.Context, option *option.AiOption, mode } // algorithm - param := &omodel.CreateMyAlgorithmParam{ - AlgorithmName: option.AlgorithmId, - ModelName: option.AlgorithmId, - } - algorithm, err := o.createAlgorithm(ctx, param) - if err != nil { - return nil, err - } - if algorithm.Code != http.StatusOK { - if algorithm.Data != nil { - marshal, err := json.Marshal(algorithm.Data) - if err != nil { - return nil, err - } - - errormdl := &omodel.Error{} - err = json.Unmarshal(marshal, errormdl) - if err != nil { - return nil, err - } - return nil, errors.New(errormdl.Message) - } - } else { - if algorithm.Data != nil { - result := &entity.OctCreateAlgorithm{} - marshal, err := json.Marshal(algorithm.Data) - if err != nil { - return nil, err - } - err = json.Unmarshal(marshal, result) - if err != nil { - return nil, err - } - if result.AlgorithmId == "" { - return nil, errors.New("createAlgorithm failed") - } - option.AlgorithmId = result.AlgorithmId - } else { - return nil, errors.New("createAlgorithm failed") - } - } + //param := &omodel.CreateMyAlgorithmParam{ + // AlgorithmName: option.AlgorithmId, + // ModelName: option.AlgorithmId, + //} + //algorithm, err := o.createAlgorithm(ctx, param) + //if err != nil { + // return nil, err + //} + //if algorithm.Code != http.StatusOK { + // if algorithm.Data != nil { + // marshal, err := json.Marshal(algorithm.Data) + // if err != nil { + // return nil, err + // } + // + // errormdl := &omodel.Error{} + // err = json.Unmarshal(marshal, errormdl) + // if err != nil { + // return nil, err + // } + // return nil, errors.New(errormdl.Message) + // } else { + // return nil, errors.New(algorithm.Msg) + // } + //} else { + // if algorithm.Data != nil { + // result := &entity.OctCreateAlgorithm{} + // marshal, err := json.Marshal(algorithm.Data) + // if err != nil { + // return nil, err + // } + // err = json.Unmarshal(marshal, result) + // if err != nil { + // return nil, err + // } + // if result.AlgorithmId == "" { + // return nil, errors.New("createAlgorithm failed") + // } + // option.AlgorithmId = result.AlgorithmId + // } else { + // return nil, errors.New("createAlgorithm failed") + // } + //} // resource option.ResourceId = "964fdee2db544928bfea74dac12a924f" @@ -217,12 +219,12 @@ func (o *OctopusHttp) SubmitTask(ctx context.Context, imageId string, cmd string param := &omodel.CreateTrainJobParam{ //DataSetId: datasetsId, //DataSetVersion: VERSION, - AlgorithmId: algorithmId, - AlgorithmVersion: AlgorithmRecordOnlyVersion, - Name: TASK_NAME_PREFIX + UNDERSCORE + utils.RandomString(10), - ImageId: imageId, - IsDistributed: false, - ResourcePool: RESOURCE_POOL, + //AlgorithmId: algorithmId, + //AlgorithmVersion: AlgorithmRecordOnlyVersion, + Name: TASK_NAME_PREFIX + UNDERSCORE + utils.RandomString(10), + ImageId: imageId, + IsDistributed: false, + ResourcePool: RESOURCE_POOL, Config: []*omodel.CreateTrainJobConf{ { Command: cmd, @@ -230,8 +232,8 @@ func (o *OctopusHttp) SubmitTask(ctx context.Context, imageId string, cmd string MinFailedTaskCount: 1, MinSucceededTaskCount: 1, TaskNumber: 1, - Parameters: prms, - Envs: envMap, + //Parameters: prms, + Envs: envMap, }, }, } @@ -265,6 +267,8 @@ func (o *OctopusHttp) createAlgorithm(ctx context.Context, param *omodel.CreateM req := common.GetRestyRequest(common.TIMEOUT) _, err = req. SetHeader("Authorization", "Bearer "+token). + SetQueryString("token=" + token). + SetQueryString("addr=" + o.host). SetBody(param). SetResult(resp). Post(createAlgorithmUrl)