| @@ -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) | |||