|
|
|
@@ -37,6 +37,7 @@ const ( |
|
|
|
ReposUrl = "/api/v1/user/repos" |
|
|
|
TaskListUrl = "/api/v1/task/list" |
|
|
|
TaskDetailsUrl = "/api/v1/task/detail" |
|
|
|
TaskLogUrl = "/api/v1/task/log" |
|
|
|
) |
|
|
|
|
|
|
|
// compute source |
|
|
|
@@ -156,7 +157,7 @@ func (o OpenI) Execute(ctx context.Context, option *option.AiOption, mode int) ( |
|
|
|
for _, s := range resp.Data.Data.Specs.All { |
|
|
|
if spec.ResType == s.ComputeResource && spec.Name == s.AccCardType { |
|
|
|
if int(spec.Number) == s.AccCardsNum { |
|
|
|
option.ResourceId = strconv.Itoa(s.Id) |
|
|
|
option.ResourceId = strconv.Itoa(s.Id) + FORWARD_SLASH + spec.ResType |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -184,10 +185,14 @@ func (o *OpenI) SubmitTask(ctx context.Context, imageId string, cmd string, envs |
|
|
|
return nil, errors.New("algorithmId format is incorrect") |
|
|
|
} |
|
|
|
|
|
|
|
specId, err := strconv.ParseInt(resourceId, 10, 0) |
|
|
|
specs := strings.Split(resourceId, FORWARD_SLASH) |
|
|
|
specId, err := strconv.ParseInt(specs[0], 10, 0) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
computeSource := specs[1] |
|
|
|
|
|
|
|
repoName = codePaths[0] |
|
|
|
branchName = codePaths[1] |
|
|
|
bootFile = codePaths[2] |
|
|
|
@@ -195,10 +200,11 @@ func (o *OpenI) SubmitTask(ctx context.Context, imageId string, cmd string, envs |
|
|
|
//params := "{\"parameter\":[{\"label\":\"a\",\"value\":\"1\"},{\"label\":\"b\",\"value\":\"2\"}]}" |
|
|
|
|
|
|
|
taskParam := &model.CreateTaskParam{ |
|
|
|
Description: algorithmId, // temporarily set reponame contained in the algorithmId to desc for missing taskdetail's reponame |
|
|
|
JobType: TRAIN, |
|
|
|
Cluster: C2NET, |
|
|
|
DisplayJobName: TRAIN + UNDERSCORE + utils.RandomString(10), |
|
|
|
ComputeSource: "", |
|
|
|
ComputeSource: computeSource, |
|
|
|
SpecId: int(specId), |
|
|
|
BranchName: branchName, |
|
|
|
ImageId: imageId, |
|
|
|
@@ -235,6 +241,7 @@ func (o *OpenI) SubmitTask(ctx context.Context, imageId string, cmd string, envs |
|
|
|
Send() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
return resp.Data, nil |
|
|
|
@@ -285,9 +292,57 @@ func (o OpenI) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm, error |
|
|
|
} |
|
|
|
|
|
|
|
func (o OpenI) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) { |
|
|
|
task, err := o.getTrainingTask(ctx, taskId) |
|
|
|
if err != nil { |
|
|
|
return "", err |
|
|
|
} |
|
|
|
|
|
|
|
codePaths := strings.Split(task.Data.Task.Description, FORWARD_SLASH) |
|
|
|
if len(codePaths) != 3 { |
|
|
|
return "", errors.New("failed to get log, openI desc not set") |
|
|
|
} |
|
|
|
|
|
|
|
repoName := codePaths[0] |
|
|
|
|
|
|
|
tasklogurl := o.host + TaskLogUrl |
|
|
|
param := model.GetLogParam{ |
|
|
|
UserName: o.userName, |
|
|
|
RepoName: repoName, |
|
|
|
Id: taskId, |
|
|
|
} |
|
|
|
|
|
|
|
b, _ := json.Marshal(param) |
|
|
|
byt := bytes.NewBuffer(b) |
|
|
|
|
|
|
|
resp := struct { |
|
|
|
Code int `json:"code"` |
|
|
|
Msg string `json:"msg"` |
|
|
|
Data model.TaskDetail `json:"data"` |
|
|
|
}{} |
|
|
|
|
|
|
|
req := common.GetRestyRequest(common.TIMEOUT) |
|
|
|
r, _ := http.NewRequest("GET", tasklogurl, byt) |
|
|
|
req.RawRequest = r |
|
|
|
req.URL = tasklogurl |
|
|
|
|
|
|
|
_, err = req. |
|
|
|
SetHeader("Content-Type", "application/json"). |
|
|
|
SetQueryParam(common.ACCESSTOKEN, o.accessToken). |
|
|
|
SetBody(byt). |
|
|
|
SetResult(&resp). |
|
|
|
Send() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
return "", errors.New("failed to invoke taskDetails") |
|
|
|
} |
|
|
|
|
|
|
|
return "", errors.New("failed to implement") |
|
|
|
} |
|
|
|
|
|
|
|
func (o OpenI) getTrainingTask(ctx context.Context, taskId string) (*model.TaskDetail, error) { |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (o OpenI) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) { |
|
|
|
taskDetailsUrl := o.host + TaskDetailsUrl |
|
|
|
|
|
|
|
|