|
|
|
@@ -63,6 +63,7 @@ const ( |
|
|
|
ResourcespecsUrl = "api/v1/resource/specs" |
|
|
|
CreateTrainJobUrl = "api/v1/job/create" |
|
|
|
TrainJobDetail = "api/v1/job/detail" |
|
|
|
TrainJobLog = "api/v1/job/log" |
|
|
|
) |
|
|
|
|
|
|
|
// compute source |
|
|
|
@@ -287,7 +288,54 @@ func (o *OctopusHttp) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm |
|
|
|
} |
|
|
|
|
|
|
|
func (o *OctopusHttp) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) { |
|
|
|
return "", errors.New(NotImplementError) |
|
|
|
taskDetailsUrl := o.server + TrainJobLog |
|
|
|
token, err := o.token.Get() |
|
|
|
if err != nil { |
|
|
|
return "", err |
|
|
|
} |
|
|
|
|
|
|
|
param := omodel.TrainJobLog{ |
|
|
|
JobId: taskId, |
|
|
|
} |
|
|
|
|
|
|
|
b, _ := json.Marshal(param) |
|
|
|
byt := bytes.NewBuffer(b) |
|
|
|
|
|
|
|
resp := &entity.OctResp{} |
|
|
|
|
|
|
|
req := common.GetRestyRequest(common.TIMEOUT) |
|
|
|
r, _ := http.NewRequest("GET", taskDetailsUrl, byt) |
|
|
|
req.RawRequest = r |
|
|
|
req.URL = taskDetailsUrl |
|
|
|
|
|
|
|
_, err = req. |
|
|
|
SetHeader("Content-Type", "application/json"). |
|
|
|
SetQueryParam(Param_Token, token). |
|
|
|
SetQueryParam(Param_Addr, o.host). |
|
|
|
SetBody(byt). |
|
|
|
SetResult(resp). |
|
|
|
Send() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
return "", errors.New("failed to invoke taskDetails") |
|
|
|
} |
|
|
|
|
|
|
|
if resp.Code != http.StatusOK { |
|
|
|
return "", errors.New("failed to invoke taskDetails") |
|
|
|
} |
|
|
|
|
|
|
|
var log string |
|
|
|
marshal, err := json.Marshal(resp.Data) |
|
|
|
if err != nil { |
|
|
|
return "", err |
|
|
|
} |
|
|
|
log = string(marshal) |
|
|
|
|
|
|
|
if strings.Contains(log, "404 Not Found") || log == "" { |
|
|
|
log = "waiting for logs..." |
|
|
|
} |
|
|
|
|
|
|
|
return log, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (o *OctopusHttp) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) { |
|
|
|
|