|
|
@@ -96,7 +96,7 @@ func CloudBrainNew(ctx *context.Context) { |
|
|
|
result, err := cloudbrain.GetImages() |
|
|
|
if err != nil { |
|
|
|
ctx.Data["error"] = err.Error() |
|
|
|
log.Error("cloudbrain.GetImages failed:", err.Error()) |
|
|
|
log.Error("cloudbrain.GetImages failed:", err.Error(), ctx.Data["msgID"]) |
|
|
|
} |
|
|
|
|
|
|
|
for i, payload := range result.Payload.ImageInfo { |
|
|
@@ -112,7 +112,7 @@ func CloudBrainNew(ctx *context.Context) { |
|
|
|
resultPublic, err := cloudbrain.GetPublicImages() |
|
|
|
if err != nil { |
|
|
|
ctx.Data["error"] = err.Error() |
|
|
|
log.Error("cloudbrain.GetPublicImages failed:", err.Error()) |
|
|
|
log.Error("cloudbrain.GetPublicImages failed:", err.Error(), ctx.Data["msgID"]) |
|
|
|
} |
|
|
|
|
|
|
|
for i, payload := range resultPublic.Payload.ImageInfo { |
|
|
@@ -164,7 +164,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath |
|
|
|
|
|
|
|
if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeSnn4imagenet) { |
|
|
|
log.Error("jobtype error:", jobType) |
|
|
|
log.Error("jobtype error:", jobType, ctx.Data["msgID"]) |
|
|
|
ctx.RenderWithErr("jobtype error", tplCloudBrainNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
@@ -267,7 +267,7 @@ func CloudBrainCommitImage(ctx *context.Context, form auth.CommitImageCloudBrain |
|
|
|
ImageTag: form.Tag, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
log.Error("CommitImage(%s) failed:", task.JobName, err.Error()) |
|
|
|
log.Error("CommitImage(%s) failed:%v", task.JobName, err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "-1", |
|
|
|
"error_msg": "CommitImage failed", |
|
|
@@ -290,14 +290,14 @@ func CloudBrainStop(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
if task.Status == string(models.JobStopped) { |
|
|
|
log.Error("the job(%s) has been stopped", task.JobName) |
|
|
|
log.Error("the job(%s) has been stopped", task.JobName, ctx.Data["msgID"]) |
|
|
|
ctx.ServerError("the job has been stopped", errors.New("the job has been stopped")) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
err = cloudbrain.StopJob(jobID) |
|
|
|
if err != nil { |
|
|
|
log.Error("StopJob(%s) failed:%v", task.JobName, err.Error()) |
|
|
|
log.Error("StopJob(%s) failed:%v", task.JobName, err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.ServerError("StopJob failed", err) |
|
|
|
return |
|
|
|
} |
|
|
@@ -321,7 +321,7 @@ func CloudBrainDel(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
if task.Status != string(models.JobStopped) { |
|
|
|
log.Error("the job(%s) has not been stopped", task.JobName) |
|
|
|
log.Error("the job(%s) has not been stopped", task.JobName, ctx.Data["msgID"]) |
|
|
|
ctx.ServerError("the job has not been stopped", errors.New("the job has not been stopped")) |
|
|
|
return |
|
|
|
} |
|
|
@@ -343,7 +343,7 @@ func CloudBrainShowModels(ctx *context.Context) { |
|
|
|
dirArray := strings.Split(parentDir, "/") |
|
|
|
task, err := models.GetCloudbrainByJobID(jobID) |
|
|
|
if err != nil { |
|
|
|
log.Error("no such job!") |
|
|
|
log.Error("no such job!", ctx.Data["msgID"]) |
|
|
|
ctx.ServerError("no such job:", err) |
|
|
|
return |
|
|
|
} |
|
|
@@ -351,7 +351,7 @@ func CloudBrainShowModels(ctx *context.Context) { |
|
|
|
//get dirs |
|
|
|
dirs, err := getModelDirs(task.JobName, parentDir) |
|
|
|
if err != nil { |
|
|
|
log.Error("getModelDirs failed:", err.Error()) |
|
|
|
log.Error("getModelDirs failed:%v", err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.ServerError("getModelDirs failed:", err) |
|
|
|
return |
|
|
|
} |
|
|
@@ -359,7 +359,7 @@ func CloudBrainShowModels(ctx *context.Context) { |
|
|
|
var fileInfos []FileInfo |
|
|
|
err = json.Unmarshal([]byte(dirs), &fileInfos) |
|
|
|
if err != nil { |
|
|
|
log.Error("json.Unmarshal failed:", err.Error()) |
|
|
|
log.Error("json.Unmarshal failed:%v", err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.ServerError("json.Unmarshal failed:", err) |
|
|
|
return |
|
|
|
} |
|
|
@@ -390,7 +390,7 @@ func CloudBrainDownloadModel(ctx *context.Context) { |
|
|
|
filePath := "jobs/" +jobName + "/model/" + parentDir |
|
|
|
url, err := storage.Attachments.PresignedGetURL(filePath, fileName) |
|
|
|
if err != nil { |
|
|
|
log.Error("PresignedGetURL failed: %v", err.Error()) |
|
|
|
log.Error("PresignedGetURL failed: %v", err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.ServerError("PresignedGetURL", err) |
|
|
|
return |
|
|
|
} |
|
|
@@ -411,13 +411,13 @@ func GetRate(ctx *context.Context) { |
|
|
|
} else if job.JobType == string(models.JobTypeSnn4imagenet) { |
|
|
|
ctx.Redirect(setting.Snn4imagenetServerHost) |
|
|
|
} else { |
|
|
|
log.Error("JobType error:", job.JobType) |
|
|
|
log.Error("JobType error:%s", job.JobType, ctx.Data["msgID"]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func downloadCode(repo *models.Repository, codePath string) error { |
|
|
|
if err := git.Clone(repo.RepoPath(), codePath, git.CloneRepoOptions{}); err != nil { |
|
|
|
log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) |
|
|
|
log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err, ctx.Data["msgID"]) |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|