Commit 5ebe8dda authored by duanjinfei's avatar duanjinfei

update standard task handler

parent c9cf1c8e
......@@ -219,35 +219,37 @@ func (t *TaskHandler) ComputeTaskHandler(taskMsg *nodeManagerV1.PushTaskMessage)
log.Error("received error: ", err)
return
}
isUseFileCache := true
for key, value := range taskParam.Headers {
if key == models.UseFileCache {
if value[0] == "0" {
isUseFileCache = false
break
if taskMsg.TaskKind == baseV1.TaskKind_StandardTask {
isUseFileCache := true
for key, value := range taskParam.Headers {
if key == models.UseFileCache {
if value[0] == "0" {
isUseFileCache = false
break
}
}
}
}
if isUseFileCache && readBody != nil {
containerResp := &models.ModelResponse{}
err = json.Unmarshal(readBody, &containerResp)
if err != nil {
log.WithError(err).Error("Error unmarshalling oss resp body failed")
return
}
if len(containerResp.Output) == 1 {
if utils.IsBase64ImageStr(containerResp.Output[0]) {
imageStr := strings.SplitN(containerResp.Output[0], ",", 2)[1]
queryString := utils.MatchFileCacheQueryString(taskParam.Headers, taskCmd.ImageName, t.DockerOp.ModelsInfo)
ossUri, err := t.uploadOSS(taskMsg.TaskId, queryString, imageStr)
if err != nil {
log.WithError(err).Error("upload image into file cache failed")
return
}
log.WithField("uri", ossUri).Info("upload image OSS successful")
if ossUri != "" {
taskExecResult.TaskHttpStatusCode = models.RedirectCode
post.Header.Set("Location", ossUri)
if isUseFileCache && readBody != nil {
containerResp := &models.ModelResponse{}
err = json.Unmarshal(readBody, &containerResp)
if err != nil {
log.WithError(err).Error("Error unmarshalling oss resp body failed")
return
}
if len(containerResp.Output) == 1 {
if utils.IsBase64ImageStr(containerResp.Output[0]) {
imageStr := strings.SplitN(containerResp.Output[0], ",", 2)[1]
queryString := utils.MatchFileCacheQueryString(taskParam.Headers, taskCmd.ImageName, t.DockerOp.ModelsInfo)
ossUri, err := t.uploadOSS(taskMsg.TaskId, queryString, imageStr)
if err != nil {
log.WithError(err).Error("upload image into file cache failed")
return
}
log.WithField("uri", ossUri).Info("upload image OSS successful")
if ossUri != "" {
taskExecResult.TaskHttpStatusCode = models.RedirectCode
post.Header.Set("Location", ossUri)
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment