你确认删除该任务么?此任务一旦删除不可恢复。
+diff --git a/models/attachment.go b/models/attachment.go index f9e697966..2dfe934a5 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -351,7 +351,7 @@ func GetUnDecompressAttachments() ([]*Attachment, error) { func getUnDecompressAttachments(e Engine) ([]*Attachment, error) { attachments := make([]*Attachment, 0, 10) - return attachments, e.Where("decompress_state = ? and dataset_id != 0 and type = ? and name like '%.zip'", DecompressStateInit, TypeCloudBrainOne).Find(&attachments) + return attachments, e.Where("decompress_state = ? and dataset_id != 0 and attachment.type = ? and name like '%.zip'", DecompressStateInit, TypeCloudBrainOne).Find(&attachments) } func GetAllPublicAttachments() ([]*AttachmentUsername, error) { @@ -361,7 +361,7 @@ func GetAllPublicAttachments() ([]*AttachmentUsername, error) { func getAllPublicAttachments(e Engine) ([]*AttachmentUsername, error) { attachments := make([]*AttachmentUsername, 0, 10) if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+ - "= `user`.id").Where("decompress_state= ? and is_private= ? and type = ?", DecompressStateDone, false, TypeCloudBrainOne).Find(&attachments); err != nil { + "= `user`.id").Where("decompress_state= ? and is_private= ? and attachment.type = ?", DecompressStateDone, false, TypeCloudBrainOne).Find(&attachments); err != nil { return nil, err } return attachments, nil @@ -379,7 +379,7 @@ func GetPrivateAttachments(username string) ([]*AttachmentUsername, error) { func getPrivateAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) { attachments := make([]*AttachmentUsername, 0, 10) if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+ - "= `user`.id").Where("decompress_state= ? and uploader_id= ? and type = ?", DecompressStateDone, userID, TypeCloudBrainOne).Find(&attachments); err != nil { + "= `user`.id").Where("decompress_state= ? and uploader_id= ? and attachment.type = ?", DecompressStateDone, userID, TypeCloudBrainOne).Find(&attachments); err != nil { return nil, err } return attachments, nil @@ -388,7 +388,7 @@ func getPrivateAttachments(e Engine, userID int64) ([]*AttachmentUsername, error func getAllUserAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) { attachments := make([]*AttachmentUsername, 0, 10) if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+ - "= `user`.id").Where("decompress_state= ? and type = ? and (uploader_id= ? or is_private = ?)", DecompressStateDone, TypeCloudBrainOne, userID, false).Find(&attachments); err != nil { + "= `user`.id").Where("decompress_state= ? and attachment.type = ? and (uploader_id= ? or is_private = ?)", DecompressStateDone, TypeCloudBrainOne, userID, false).Find(&attachments); err != nil { return nil, err } return attachments, nil @@ -401,7 +401,7 @@ func GetAllUserAttachments(userID int64) ([]*AttachmentUsername, error) { func getModelArtsUserAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) { attachments := make([]*AttachmentUsername, 0, 10) if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+ - "= `user`.id").Where("type = ? and (uploader_id= ? or is_private = ?)", TypeCloudBrainTwo, userID, false).Find(&attachments); err != nil { + "= `user`.id").Where("attachment.type = ? and (uploader_id= ? or is_private = ?)", TypeCloudBrainTwo, userID, false).Find(&attachments); err != nil { return nil, err } return attachments, nil diff --git a/modules/auth/modelarts.go b/modules/auth/modelarts.go index b15de3c37..1bef4c825 100755 --- a/modules/auth/modelarts.go +++ b/modules/auth/modelarts.go @@ -7,10 +7,7 @@ import ( type CreateModelArtsForm struct { JobName string `form:"job_name" binding:"Required"` - Image string `form:"image" binding:"Required"` - Command string `form:"command" binding:"Required"` Attachment string `form:"attachment" binding:"Required"` - JobType string `form:"job_type" binding:"Required"` } func (f *CreateModelArtsForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { diff --git a/modules/modelarts/modelarts.go b/modules/modelarts/modelarts.go index abfe2a398..3cae0f2c6 100755 --- a/modules/modelarts/modelarts.go +++ b/modules/modelarts/modelarts.go @@ -17,7 +17,10 @@ const ( subTaskName = "task1" - DataSetMountPath = "/home/ma-user/work" + DataSetMountPath = "/home/ma-user/work" + NotebookEnv = "Python3" + NotebookType = "Ascend" + FlavorInfo = "Ascend: 1*Ascend 910 CPU: 24 核 96GiB (modelarts.kat1.xlarge)" ) func GenerateTask(ctx *context.Context, jobName, uuid string) error { diff --git a/modules/modelarts/resty.go b/modules/modelarts/resty.go index 2c225c603..b8be5ec6d 100755 --- a/modules/modelarts/resty.go +++ b/modules/modelarts/resty.go @@ -35,7 +35,10 @@ func checkSetting() { return } - getToken() + err := getToken() + if err != nil { + log.Error("getToken falied:", err.Error()) + } } func getToken() error { diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index defb0b858..8b3c71e4f 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -82,20 +82,26 @@ func ModelArtsNew(ctx *context.Context) { ctx.Data["attachments"] = attachs ctx.Data["dataset_path"] = modelarts.DataSetMountPath + ctx.Data["env"] = modelarts.NotebookEnv + ctx.Data["notebook_type"] = modelarts.NotebookType + ctx.Data["flavor"] = modelarts.FlavorInfo ctx.HTML(200, tplModelArtsNew) } -func ModelArtsCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { +func ModelArtsCreate(ctx *context.Context, form auth.CreateModelArtsForm) { ctx.Data["PageIsCloudBrain"] = true jobName := form.JobName uuid := form.Attachment //repo := ctx.Repo.Repository + log.Info(uuid) + err := modelarts.GenerateTask(ctx, jobName, uuid) if err != nil { ctx.RenderWithErr(err.Error(), tplModelArtsNew, &form) return } + ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts") } diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 75d67853b..ac4776a2c 100755 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -220,7 +220,7 @@ if(checked_radio=='0'){ window.location.href = repolink+'/cloudbrain' }else if(checked_radio=='1'){ - window.location.href = repolink+'/blockchain' + window.location.href = repolink+'/modelarts' }else{ return; diff --git a/templates/repo/modelarts/index.tmpl b/templates/repo/modelarts/index.tmpl new file mode 100755 index 000000000..e65f554d1 --- /dev/null +++ b/templates/repo/modelarts/index.tmpl @@ -0,0 +1,492 @@ + +{{template "base/head" .}} + + + + +
你确认删除该任务么?此任务一旦删除不可恢复。
+任务名称: {{.JobName}}
+ {{end}} +任务结果:
+ {{with .taskRes}} + {{range .TaskStatuses}} +状态 | +{{.State}} | +
开始时间 | +{{.StartTime}} | +
结束时间 | +{{.FinishedTime}} | +
ExitCode | +{{.ExitCode}} | +
退出信息 | +{{.ExitDiagnostics| nl2br}} | +
硬件信息 | |
---|---|
CPU | +{{.Resource.CPU}} | +
Memory | +{{.Resource.Memory}} | +
NvidiaComGpu | +{{.Resource.NvidiaComGpu}} | +
调试信息 | |
---|---|
状态 | +{{.Platform}} | +
开始时间 | +{{.JobStatus.StartTime}} | +
结束时间 | +{{.JobStatus.EndTime}} | +
ExitCode | +{{.JobStatus.AppExitCode}} | +
退出信息 | +{{.JobStatus.AppExitDiagnostics | nl2br}} | +