| @@ -31,6 +31,7 @@ const ( | |||
| JobTypeBrainScore JobType = "BRAINSCORE" | |||
| JobTypeTrain JobType = "TRAIN" | |||
| //notebook | |||
| ModelArtsCreateQueue ModelArtsJobStatus = "CREATE_QUEUING" //免费资源创建排队中 | |||
| ModelArtsCreating ModelArtsJobStatus = "CREATING" //创建中 | |||
| ModelArtsCreateFailed ModelArtsJobStatus = "CREATE_FAILED" //创建失败 | |||
| @@ -46,6 +47,30 @@ const ( | |||
| ModelArtsDeleted ModelArtsJobStatus = "DELETED" //已删除 | |||
| ModelArtsResizing ModelArtsJobStatus = "RESIZING" //规格变更中 | |||
| ModelArtsResizFailed ModelArtsJobStatus = "RESIZE_FAILED" //规格变更失败 | |||
| //trainjob | |||
| ModelArtsTrainJobUnknown ModelArtsJobStatus = "UNKNOWN" //作业状态未知 | |||
| ModelArtsTrainJobInit ModelArtsJobStatus = "INIT" //作业初始化状态 | |||
| ModelArtsTrainJobImageCreating ModelArtsJobStatus = "IMAGE_CREATING" //作业镜像正在创建 | |||
| ModelArtsTrainJobImageFailed ModelArtsJobStatus = "IMAGE_FAILED" //作业镜像创建失败 | |||
| ModelArtsTrainJobSubmitTrying ModelArtsJobStatus = "SUBMIT_TRYING" //作业正在提交 | |||
| ModelArtsTrainJobSubmitFailed ModelArtsJobStatus = "SUBMIT_FAILED" //作业提交失败 | |||
| ModelArtsTrainJobDeleteFailed ModelArtsJobStatus = "DELETE_FAILED" //作业删除失败 | |||
| ModelArtsTrainJobWaiting ModelArtsJobStatus = "WAITING" //作业正在排队中 | |||
| ModelArtsTrainJobRunning ModelArtsJobStatus = "RUNNING" //作业正在运行中 | |||
| ModelArtsTrainJobKilling ModelArtsJobStatus = "KILLING" //作业正在取消 | |||
| ModelArtsTrainJobCompleted ModelArtsJobStatus = "COMPLETED" //作业已经完成 | |||
| ModelArtsTrainJobFailed ModelArtsJobStatus = "FAILED" //作业运行失败 | |||
| ModelArtsTrainJobKilled ModelArtsJobStatus = "KILLED" //作业取消成功 | |||
| ModelArtsTrainJobCanceled ModelArtsJobStatus = "CANCELED" //作业取消 | |||
| ModelArtsTrainJobLost ModelArtsJobStatus = "LOST" //作业丢失 | |||
| ModelArtsTrainJobScaling ModelArtsJobStatus = "SCALING" //作业正在扩容 | |||
| ModelArtsTrainJobSubmitModelFailed ModelArtsJobStatus = "SUBMIT_MODEL_FAILED" //提交模型失败 | |||
| ModelArtsTrainJobDeployServiceFailed ModelArtsJobStatus = "DEPLOY_SERVICE_FAILED" //部署服务失败 | |||
| ModelArtsTrainJobCheckInit ModelArtsJobStatus = "CHECK_INIT" //审核作业初始化 | |||
| ModelArtsTrainJobCheckRunning ModelArtsJobStatus = "CHECK_RUNNING" //审核作业正在运行中 | |||
| ModelArtsTrainJobCheckRunningCompleted ModelArtsJobStatus = "CHECK_RUNNING_COMPLETED" //审核作业已经完成 | |||
| ModelArtsTrainJobCheckFailed ModelArtsJobStatus = "CHECK_FAILED" //审核作业失败 | |||
| ) | |||
| type Cloudbrain struct { | |||
| @@ -1091,3 +1116,14 @@ func CanDelJob(isSigned bool, user *User, job *CloudbrainInfo) bool { | |||
| } | |||
| return false | |||
| } | |||
| func GetCloudBrainUnStoppedJob() ([]*Cloudbrain, error) { | |||
| cloudbrains := make([]*Cloudbrain, 0, 10) | |||
| return cloudbrains, x. | |||
| NotIn("status", | |||
| JobStopped, JobSucceeded, JobFailed, ModelArtsCreateFailed, ModelArtsStartFailed, ModelArtsUnavailable, ModelArtsResizFailed, ModelArtsDeleted, | |||
| ModelArtsStopped, ModelArtsTrainJobCanceled, ModelArtsTrainJobCheckFailed, ModelArtsTrainJobCompleted, ModelArtsTrainJobDeleteFailed, ModelArtsTrainJobDeployServiceFailed, | |||
| ModelArtsTrainJobFailed, ModelArtsTrainJobImageFailed, ModelArtsTrainJobKilled, ModelArtsTrainJobLost, ModelArtsTrainJobSubmitFailed, ModelArtsTrainJobSubmitModelFailed). | |||
| Limit(100). | |||
| Find(&cloudbrains) | |||
| } | |||
| @@ -145,6 +145,7 @@ type User struct { | |||
| AllowImportLocal bool // Allow migrate repository by local path | |||
| AllowCreateOrganization bool `xorm:"DEFAULT true"` | |||
| ProhibitLogin bool `xorm:"NOT NULL DEFAULT false"` | |||
| IsOperator bool `xorm:"NOT NULL DEFAULT false"` //运营人员 | |||
| // Avatar | |||
| Avatar string `xorm:"VARCHAR(2048) NOT NULL"` | |||
| @@ -9,6 +9,9 @@ import ( | |||
| "reflect" | |||
| "strings" | |||
| "code.gitea.io/gitea/modules/base" | |||
| "code.gitea.io/gitea/modules/setting" | |||
| "code.gitea.io/gitea/models" | |||
| "code.gitea.io/gitea/modules/auth/sso" | |||
| "code.gitea.io/gitea/modules/validation" | |||
| @@ -31,6 +34,8 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (*models.User, bool) | |||
| return nil, false | |||
| } | |||
| checkAutoLogin(ctx, sess) | |||
| // Try to sign in with each of the enabled plugins | |||
| for _, ssoMethod := range sso.Methods() { | |||
| if !ssoMethod.IsEnabled() { | |||
| @@ -46,6 +51,23 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (*models.User, bool) | |||
| return nil, false | |||
| } | |||
| func checkAutoLogin(ctx *macaron.Context, sess session.Store) { | |||
| uid := sess.Get("uid") | |||
| if uid == nil { | |||
| uname := ctx.GetCookie(setting.CookieUserName) | |||
| u, err := models.GetUserByName(uname) | |||
| if err == nil { | |||
| if val, ok := ctx.GetSuperSecureCookie( | |||
| base.EncodeMD5(u.Rands+u.Passwd), setting.CookieRememberName); ok && val == u.Name { | |||
| sess.Set("uid", u.ID) | |||
| } | |||
| } | |||
| } | |||
| } | |||
| // Form form binding interface | |||
| type Form interface { | |||
| binding.Validator | |||
| @@ -145,8 +145,7 @@ func Toggle(options *ToggleOptions) macaron.Handler { | |||
| } | |||
| if options.OperationRequired { | |||
| //todo: add isOperator judgement | |||
| if !ctx.User.IsAdmin { | |||
| if !ctx.User.IsOperator { | |||
| ctx.Error(403) | |||
| return | |||
| } | |||
| @@ -310,6 +310,7 @@ func Contexter() macaron.Handler { | |||
| ctx.Data["SignedUserID"] = ctx.User.ID | |||
| ctx.Data["SignedUserName"] = ctx.User.Name | |||
| ctx.Data["IsAdmin"] = ctx.User.IsAdmin | |||
| ctx.Data["IsOperator"] = ctx.User.IsOperator | |||
| c.Data["SignedUserName"] = ctx.User.Name | |||
| } else { | |||
| ctx.Data["SignedUserID"] = int64(0) | |||
| @@ -185,6 +185,17 @@ func registerHandleSummaryStatistic() { | |||
| }) | |||
| } | |||
| func registerSyncCloudbrainStatus() { | |||
| RegisterTaskFatal("sync_cloudbrain_status", &BaseConfig{ | |||
| Enabled: true, | |||
| RunAtStart: false, | |||
| Schedule: "@every 10m", | |||
| }, func(ctx context.Context, _ *models.User, _ Config) error { | |||
| repo.SyncCloudbrainStatus() | |||
| return nil | |||
| }) | |||
| } | |||
| func initBasicTasks() { | |||
| registerUpdateMirrorTask() | |||
| registerRepoHealthCheck() | |||
| @@ -202,4 +213,6 @@ func initBasicTasks() { | |||
| registerHandleRepoAndUserStatistic() | |||
| registerHandleSummaryStatistic() | |||
| registerSyncCloudbrainStatus() | |||
| } | |||
| @@ -0,0 +1 @@ | |||
| <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1638325192035" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2222" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M979.792374 404.577188 574.183101 83.942886c-34.918864-27.694272-89.619352-27.694272-124.538216 0L44.207626 404.577188c-13.933143 11.008903-16.169326 31.134554-5.332437 44.895683s30.618512 16.169326 44.551655 5.332437l12.55703-10.320847 0 387.547791c0 54.872501 57.968755 95.983874 108.712918 95.983874l639.892491 0c50.22812 0 83.254829-38.531161 83.254829-95.983874L927.844112 445.860575l11.69696 8.944734c5.84848 4.644381 13.073072 6.880564 20.125651 6.880564 9.460776 0 18.921552-4.128339 25.286074-12.213002C995.9617 435.711742 993.725517 415.586091 979.792374 404.577188zM479.919368 864.026877 479.919368 686.508315c0-8.77272 15.997312-13.245087 31.994625-13.245087s31.994625 4.472367 31.994625 13.245087l0 177.346548L479.919368 864.026877 479.919368 864.026877zM864.026877 832.032253c0 21.157736-5.84848 31.994625-19.26558 31.994625L608.585923 864.026877c0-0.516042-0.688056-0.860071-0.688056-1.376113L607.897867 686.508315c0-37.155048-29.930455-77.234336-95.983874-77.234336s-95.983874 40.079288-95.983874 77.234336l0 176.142449c0 0.516042 0.860071 0.860071 0.860071 1.376113L204.868806 864.026877c-20.125651 0-44.723669-17.373425-44.723669-31.994625L160.145137 393.740299 488.864102 134.171006c11.868974-9.288762 33.198723-9.288762 44.895683 0l330.095078 261.11742L863.854863 832.032253z" p-id="2223" fill="#1684FC"></path></svg> | |||
| @@ -0,0 +1 @@ | |||
| <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1638171446718" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2430" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M512 69.717333l383.018667 221.141334v442.282666L512 954.282667 128.981333 733.141333V290.858667L512 69.717333zM192.96 375.402667v320.768L480 861.888V541.141333l-287.04-165.76z m638.058667 0L544 541.162667V861.866667l287.018667-165.717334V375.424zM512 143.637333L215.722667 314.666667 512 485.717333l296.256-171.050666L512 143.616z" fill="#1684FC" p-id="2431"></path></svg> | |||
| @@ -0,0 +1 @@ | |||
| <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1638171175505" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2087" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M947.924 963.76c0 21.752-17.62 39.372-39.354 39.372-21.75 0-39.37-17.62-39.37-39.371l-0.354-3.655c0-1.554 0.283-3.054 0.442-4.59-24.576-172.792-172.72-299.768-353.104-301.763-1.447 0.036-2.825 0.23-4.29 0.23-1.43 0-2.807-0.194-4.237-0.23C329.34 655.731 182.607 779.9 155.56 949.69c0.9 3.337 1.536 6.78 1.536 10.4l0.37 3.707c0 22.086-17.902 39.989-39.97 39.989s-39.99-17.903-39.99-39.99l-0.035-0.352h-0.76c0.107-1.165 0.336-2.278 0.46-3.425 0-3.302 0.53-6.427 1.27-9.499C98.94 791.217 205.684 662.422 350.968 606.95c-84.586-54.2-139.74-149.963-139.74-259.372 0-169.224 131.478-306.405 300.702-306.405 169.208 0 300.703 137.18 300.703 306.405 0 109.374-55.102 205.118-139.652 259.32 144.278 55.03 250.544 182.325 272.19 340.038 1.465 4.131 2.436 8.528 2.436 13.17l0.318 3.656z m-204.43-616.094c0-127.947-103.706-231.654-231.653-231.654S280.188 219.736 280.188 347.666c0 127.929 103.724 231.636 231.653 231.636s231.654-103.707 231.654-231.636z" fill="#1684FC" p-id="2088"></path></svg> | |||
| @@ -75,6 +75,7 @@ import ( | |||
| "code.gitea.io/gitea/routers/api/v1/repo" | |||
| _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation | |||
| "code.gitea.io/gitea/routers/api/v1/user" | |||
| repo_ext "code.gitea.io/gitea/routers/repo" | |||
| "gitea.com/macaron/binding" | |||
| "gitea.com/macaron/macaron" | |||
| @@ -523,23 +524,26 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
| Get(notify.GetThread). | |||
| Patch(notify.ReadThread) | |||
| }, reqToken()) | |||
| adminReq := context.Toggle(&context.ToggleOptions{SignInRequired: true, AdminRequired: true}) | |||
| operationReq := context.Toggle(&context.ToggleOptions{SignInRequired: true, OperationRequired: true}) | |||
| //Project board | |||
| m.Group("/projectboard", func() { | |||
| m.Get("/restoreFork", adminReq, repo.RestoreForkNumber) | |||
| m.Get("/downloadAll", adminReq, repo.ServeAllProjectsPeriodStatisticsFile) | |||
| m.Get("/downloadAllOpenI", adminReq, repo.ServeAllProjectsOpenIStatisticsFile) | |||
| m.Get("/restoreFork", repo.RestoreForkNumber) | |||
| m.Get("/downloadAll", repo.ServeAllProjectsPeriodStatisticsFile) | |||
| m.Get("/downloadAllOpenI", repo.ServeAllProjectsOpenIStatisticsFile) | |||
| m.Group("/project", func() { | |||
| m.Get("", adminReq, repo.GetAllProjectsPeriodStatistics) | |||
| m.Get("", repo.GetAllProjectsPeriodStatistics) | |||
| m.Group("/:id", func() { | |||
| m.Get("", adminReq, repo.GetProjectLatestStatistics) | |||
| m.Get("/period", adminReq, repo.GetProjectPeriodStatistics) | |||
| m.Get("", repo.GetProjectLatestStatistics) | |||
| m.Get("/period", repo.GetProjectPeriodStatistics) | |||
| }) | |||
| }) | |||
| }) | |||
| }, operationReq) | |||
| m.Get("/query_user_static_page", operationReq, repo_ext.QueryUserStaticDataPage) | |||
| // Users | |||
| m.Group("/users", func() { | |||
| @@ -715,3 +715,78 @@ func downloadRateCode(repo *models.Repository, taskName, gitPath, codePath, benc | |||
| return nil | |||
| } | |||
| func SyncCloudbrainStatus() { | |||
| cloudBrains, err := models.GetCloudBrainUnStoppedJob() | |||
| if err != nil { | |||
| log.Error("GetCloudBrainUnStoppedJob failed:", err.Error()) | |||
| return | |||
| } | |||
| for _, task := range cloudBrains { | |||
| if task.Type == models.TypeCloudBrainOne { | |||
| result, err := cloudbrain.GetJob(task.JobID) | |||
| if err != nil { | |||
| log.Error("GetJob(%s) failed:%v", task.JobName, err) | |||
| continue | |||
| } | |||
| if result != nil { | |||
| jobRes, _ := models.ConvertToJobResultPayload(result.Payload) | |||
| taskRoles := jobRes.TaskRoles | |||
| taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | |||
| task.Status = taskRes.TaskStatuses[0].State | |||
| if task.Status != string(models.JobWaiting) { | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob(%s) failed:%v", task.JobName, err) | |||
| continue | |||
| } | |||
| } | |||
| } | |||
| } else if task.Type == models.TypeCloudBrainTwo { | |||
| if task.JobType == string(models.JobTypeDebug) { | |||
| result, err := modelarts.GetJob(task.JobID) | |||
| if err != nil { | |||
| log.Error("GetJob(%s) failed:%v", task.JobName, err) | |||
| continue | |||
| } | |||
| if result != nil { | |||
| task.Status = result.Status | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob(%s) failed:%v", task.JobName, err) | |||
| continue | |||
| } | |||
| } | |||
| } else if task.JobType == string(models.JobTypeTrain) { | |||
| result, err := modelarts.GetTrainJob(task.JobID, strconv.FormatInt(task.VersionID, 10)) | |||
| if err != nil { | |||
| log.Error("GetTrainJob(%s) failed:%v", task.JobName, err) | |||
| continue | |||
| } | |||
| if result != nil { | |||
| task.Status = modelarts.TransTrainJobStatus(result.IntStatus) | |||
| task.Duration = result.Duration | |||
| task.TrainJobDuration = result.TrainJobDuration | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| log.Error("UpdateJob(%s) failed:%v", task.JobName, err) | |||
| continue | |||
| } | |||
| } | |||
| } else { | |||
| log.Error("task.JobType(%s) is error:%s", task.JobName, task.JobType) | |||
| } | |||
| } else { | |||
| log.Error("task.Type(%s) is error:%d", task.JobName, task.Type) | |||
| } | |||
| } | |||
| return | |||
| } | |||
| @@ -4,7 +4,6 @@ import ( | |||
| "encoding/json" | |||
| "errors" | |||
| "io" | |||
| "io/ioutil" | |||
| "net/http" | |||
| "os" | |||
| "path" | |||
| @@ -386,7 +385,7 @@ func trainJobNewDataPrepare(ctx *context.Context) error { | |||
| return nil | |||
| } | |||
| func ErrorNewDataPrepare(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) error { | |||
| func trainJobErrorNewDataPrepare(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) error { | |||
| ctx.Data["PageIsCloudBrain"] = true | |||
| //can, err := canUserCreateTrainJob(ctx.User.ID) | |||
| @@ -574,7 +573,7 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error { | |||
| return nil | |||
| } | |||
| func VersionErrorDataPrepare(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) error { | |||
| func versionErrorDataPrepare(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) error { | |||
| ctx.Data["PageIsCloudBrain"] = true | |||
| var jobID = ctx.Params(":jobid") | |||
| // var versionName = ctx.Params(":version-name") | |||
| @@ -690,22 +689,23 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||
| if err := paramCheckCreateTrainJob(form); err != nil { | |||
| log.Error("paramCheckCreateTrainJob failed:(%v)", err) | |||
| ErrorNewDataPrepare(ctx, form) | |||
| trainJobErrorNewDataPrepare(ctx, form) | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobNew, &form) | |||
| return | |||
| } | |||
| attach, err := models.GetAttachmentByUUID(uuid) | |||
| if err != nil { | |||
| log.Error("GetAttachmentByUUID(%s) failed:%v", uuid, err.Error()) | |||
| return | |||
| } | |||
| // attach, err := models.GetAttachmentByUUID(uuid) | |||
| // if err != nil { | |||
| // log.Error("GetAttachmentByUUID(%s) failed:%v", uuid, err.Error()) | |||
| // return | |||
| // } | |||
| //todo: del the codeLocalPath | |||
| _, err = ioutil.ReadDir(codeLocalPath) | |||
| if err == nil { | |||
| os.RemoveAll(codeLocalPath) | |||
| } | |||
| // _, err := ioutil.ReadDir(codeLocalPath) | |||
| // if err == nil { | |||
| // os.RemoveAll(codeLocalPath) | |||
| // } | |||
| os.RemoveAll(codeLocalPath) | |||
| gitRepo, _ := git.OpenRepository(repo.RepoPath()) | |||
| commitID, _ := gitRepo.GetBranchCommitID(branch_name) | |||
| @@ -714,7 +714,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||
| Branch: branch_name, | |||
| }); err != nil { | |||
| log.Error("创建任务失败,服务器超时!: %s (%v)", repo.FullName(), err) | |||
| trainJobNewDataPrepare(ctx) | |||
| trainJobErrorNewDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("创建任务失败,服务器超时!", tplModelArtsTrainJobNew, &form) | |||
| return | |||
| } | |||
| @@ -722,14 +722,14 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||
| //todo: upload code (send to file_server todo this work?) | |||
| if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.OutputPath + VersionOutputPath + "/"); err != nil { | |||
| log.Error("Failed to obsMkdir_output: %s (%v)", repo.FullName(), err) | |||
| trainJobNewDataPrepare(ctx) | |||
| trainJobErrorNewDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("Failed to obsMkdir_output", tplModelArtsTrainJobNew, &form) | |||
| return | |||
| } | |||
| if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.LogPath + VersionOutputPath + "/"); err != nil { | |||
| log.Error("Failed to obsMkdir_log: %s (%v)", repo.FullName(), err) | |||
| trainJobNewDataPrepare(ctx) | |||
| trainJobErrorNewDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("Failed to obsMkdir_log", tplModelArtsTrainJobNew, &form) | |||
| return | |||
| } | |||
| @@ -738,7 +738,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||
| if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { | |||
| // if err := uploadCodeToObs(codeLocalPath, jobName, parentDir); err != nil { | |||
| log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err) | |||
| trainJobNewDataPrepare(ctx) | |||
| trainJobErrorNewDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("Failed to uploadCodeToObs", tplModelArtsTrainJobNew, &form) | |||
| return | |||
| } | |||
| @@ -758,7 +758,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||
| err := json.Unmarshal([]byte(params), ¶meters) | |||
| if err != nil { | |||
| log.Error("Failed to Unmarshal params: %s (%v)", params, err) | |||
| trainJobNewDataPrepare(ctx) | |||
| trainJobErrorNewDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("运行参数错误", tplModelArtsTrainJobNew, &form) | |||
| return | |||
| } | |||
| @@ -801,7 +801,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||
| if err != nil { | |||
| log.Error("Failed to CreateTrainJobConfig: %v", err) | |||
| trainJobNewDataPrepare(ctx) | |||
| trainJobErrorNewDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("保存作业参数失败:"+err.Error(), tplModelArtsTrainJobNew, &form) | |||
| return | |||
| } | |||
| @@ -839,15 +839,10 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||
| return | |||
| } | |||
| err = modelarts.GenerateTrainJob(ctx, req) | |||
| err := modelarts.GenerateTrainJob(ctx, req) | |||
| if err != nil { | |||
| log.Error("GenerateTrainJob failed:%v", err.Error()) | |||
| trainJobNewDataPrepare(ctx) | |||
| ctx.Data["bootFile"] = form.BootFile | |||
| ctx.Data["uuid"] = form.Attachment | |||
| ctx.Data["datasetName"] = attach.Name | |||
| ctx.Data["params"] = Parameters.Parameter | |||
| ctx.Data["branch_name"] = branch_name | |||
| trainJobErrorNewDataPrepare(ctx, form) | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobNew, &form) | |||
| return | |||
| } | |||
| @@ -896,7 +891,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ | |||
| if err := paramCheckCreateTrainJob(form); err != nil { | |||
| log.Error("paramCheckCreateTrainJob failed:(%v)", err) | |||
| VersionErrorDataPrepare(ctx, form) | |||
| versionErrorDataPrepare(ctx, form) | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobVersionNew, &form) | |||
| return | |||
| } | |||
| @@ -920,7 +915,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ | |||
| Branch: branch_name, | |||
| }); err != nil { | |||
| log.Error("创建任务失败,任务名称已存在!: %s (%v)", repo.FullName(), err) | |||
| VersionErrorDataPrepare(ctx, form) | |||
| versionErrorDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("创建任务失败,任务名称已存在!", tplModelArtsTrainJobVersionNew, &form) | |||
| return | |||
| } | |||
| @@ -928,14 +923,14 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ | |||
| //todo: upload code (send to file_server todo this work?) | |||
| if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.OutputPath + VersionOutputPath + "/"); err != nil { | |||
| log.Error("Failed to obsMkdir_output: %s (%v)", repo.FullName(), err) | |||
| VersionErrorDataPrepare(ctx, form) | |||
| versionErrorDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("Failed to obsMkdir_output", tplModelArtsTrainJobVersionNew, &form) | |||
| return | |||
| } | |||
| if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.LogPath + VersionOutputPath + "/"); err != nil { | |||
| log.Error("Failed to obsMkdir_log: %s (%v)", repo.FullName(), err) | |||
| VersionErrorDataPrepare(ctx, form) | |||
| versionErrorDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("Failed to obsMkdir_log", tplModelArtsTrainJobVersionNew, &form) | |||
| return | |||
| } | |||
| @@ -945,7 +940,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ | |||
| // if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { | |||
| if err := uploadCodeToObs(codeLocalPath, jobName, parentDir); err != nil { | |||
| log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err) | |||
| VersionErrorDataPrepare(ctx, form) | |||
| versionErrorDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("Failed to uploadCodeToObs", tplModelArtsTrainJobVersionNew, &form) | |||
| return | |||
| } | |||
| @@ -965,7 +960,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ | |||
| err := json.Unmarshal([]byte(params), ¶meters) | |||
| if err != nil { | |||
| log.Error("Failed to Unmarshal params: %s (%v)", params, err) | |||
| VersionErrorDataPrepare(ctx, form) | |||
| versionErrorDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("运行参数错误", tplModelArtsTrainJobVersionNew, &form) | |||
| return | |||
| } | |||
| @@ -984,7 +979,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ | |||
| if isSaveParam == "on" { | |||
| if form.ParameterTemplateName == "" { | |||
| log.Error("ParameterTemplateName is empty") | |||
| VersionErrorDataPrepare(ctx, form) | |||
| versionErrorDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("保存作业参数时,作业参数名称不能为空", tplModelArtsTrainJobVersionNew, &form) | |||
| return | |||
| } | |||
| @@ -1008,7 +1003,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ | |||
| if err != nil { | |||
| log.Error("Failed to CreateTrainJobConfig: %v", err) | |||
| VersionErrorDataPrepare(ctx, form) | |||
| versionErrorDataPrepare(ctx, form) | |||
| ctx.RenderWithErr("保存作业参数失败:"+err.Error(), tplModelArtsTrainJobVersionNew, &form) | |||
| return | |||
| } | |||
| @@ -1055,7 +1050,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ | |||
| err = modelarts.GenerateTrainJobVersion(ctx, req, jobID) | |||
| if err != nil { | |||
| log.Error("GenerateTrainJob failed:%v", err.Error()) | |||
| VersionErrorDataPrepare(ctx, form) | |||
| versionErrorDataPrepare(ctx, form) | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobVersionNew, &form) | |||
| return | |||
| } | |||
| @@ -792,7 +792,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
| }, reqSignIn, context.RepoAssignment(), context.UnitTypes(), reqRepoAdmin, context.RepoRef()) | |||
| m.Post("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), context.UnitTypes(), repo.Action) | |||
| m.Get("/tool/query_user_static_page", adminReq, repo.QueryUserStaticDataPage) | |||
| // Grouping for those endpoints not requiring authentication | |||
| m.Group("/:username/:reponame", func() { | |||
| m.Get("/contributors", repo.Contributors) | |||
| @@ -37,7 +37,7 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsAdmin}} | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| </div> | |||
| @@ -55,7 +55,7 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsAdmin}} | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| </div> | |||
| @@ -37,7 +37,7 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsAdmin}} | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| </div> | |||
| @@ -55,7 +55,7 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsAdmin}} | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| </div> | |||
| @@ -29,7 +29,7 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsAdmin}} | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| </div> | |||
| @@ -47,7 +47,7 @@ | |||
| <a class="item" href="{{AppSubUrl}}/explore/users">{{.i18n.Tr "explore.users"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "explore.organizations"}}</a> | |||
| <a class="item" href="{{AppSubUrl}}/explore/images">{{.i18n.Tr "explore.images"}}</a> | |||
| {{if .IsAdmin}} | |||
| {{if .IsOperator}} | |||
| <a class="item" href="{{AppSubUrl}}/explore/data_analysis">{{.i18n.Tr "explore.data_analysis"}}</a> | |||
| {{end}} | |||
| </div> | |||
| @@ -3,7 +3,7 @@ | |||
| <el-tabs tab-position="left" v-model="activeName" style="height:100%" @tab-click="handleClick" > | |||
| <el-tab-pane label="概览" name="first" > | |||
| <span slot="label"> | |||
| <el-image style="width: 13px; height: 13px" src="/img/overview.png"> | |||
| <el-image style="width: 13px; height: 13px" src="/img/overview_rgb.svg"> | |||
| </el-image> | |||
| 概览 | |||
| </span> | |||
| @@ -13,14 +13,14 @@ | |||
| <el-tab-pane label="项目分析" name="second" id="second" > | |||
| <ProAnalysis ref='ProAnalysis'id="pro" v-if="isRouterAlive"></ProAnalysis> | |||
| <span slot="label"> | |||
| <el-image style="width: 13px; height: 13px" src="/img/pro_new.svg"> | |||
| <el-image style="width: 13px; height: 13px" src="/img/pro_rgb.svg"> | |||
| </el-image> | |||
| 项目分析 | |||
| </span> | |||
| </el-tab-pane> | |||
| <el-tab-pane name="third" id='third' > | |||
| <span slot='label'> | |||
| <el-image style="width: 13px; height: 13px" src="/img/name.png"> | |||
| <el-image style="width: 13px; height: 13px" src="/img/user_rgb.svg"> | |||
| </el-image> | |||
| 用户分析 | |||
| </span> | |||
| @@ -121,6 +121,14 @@ | |||
| /deep/ .el-tabs__item { | |||
| padding: 0px 20px 0px 20px; | |||
| } | |||
| /deep/ .el-tabs__item.is-active .el-image{ | |||
| filter:none | |||
| } | |||
| /deep/ .el-tabs__item:hover .el-image{ | |||
| filter:none | |||
| } | |||
| /deep/ .el-image{ | |||
| filter:grayscale(100%) | |||
| } | |||
| </style> | |||
| @@ -1085,6 +1085,12 @@ | |||
| return data[0]+''+data[1]+''+data[2] | |||
| } | |||
| }, | |||
| goBack(){ | |||
| if( $("#pro_detail").is(':visible') ){ | |||
| document.getElementById("pro_main").style.display = "block"; | |||
| document.getElementById("pro_detail").style.display = "none"; | |||
| } | |||
| }, | |||
| }, | |||
| filters:{ | |||
| @@ -1125,7 +1131,7 @@ | |||
| return " <a href=\" mailto:" + value.email + "class=\"circular ui button\">" +value.user+ "</a>" | |||
| } | |||
| }, | |||
| }, | |||
| }, | |||
| @@ -1140,6 +1146,10 @@ | |||
| this.radarOpenI = this.$echarts.init(document.getElementById('radar_openi')) | |||
| this.echartsOITd = this.$echarts.init(document.getElementById('line_openi')) | |||
| this.echartsSelectData = this.$echarts.init(document.getElementById('selectData')) | |||
| if (window.history && window.history.pushState) { | |||
| history.pushState(null, null, document.URL); | |||
| window.addEventListener('popstate', this.goBack, false); | |||
| } | |||
| // window.onresize=function(){ | |||
| // this.radarOpenI.resize(); | |||
| // this.echartsOITd.resize(); | |||
| @@ -27,10 +27,10 @@ | |||
| </span> | |||
| <span style="float:right; margin-right: 20px;" > | |||
| <a style="display:inline-block;margin-left: 20px; " id = 'download'> | |||
| <a class="el-icon-download" v-if="tableData!=''" :href= "'../tool/query_user_static_page/?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" ></a> | |||
| <a class="el-icon-download" v-if="tableData!=''" :href= "'../api/v1/query_user_static_page/?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" ></a> | |||
| <i class="el-icon-download" v-else="tableData=''" href="#" style="color:rgba(187, 187, 187, 100);" @click='popMark()'></i> | |||
| <span > | |||
| <a v-if="tableData!=''" :href= "'../tool/query_user_static_page/?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" >下载报告</a> | |||
| <a v-if="tableData!=''" :href= "'../api/v1/query_user_static_page/?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" >下载报告</a> | |||
| <a v-else="tableData=''" href= "#" style="color:rgba(187, 187, 187, 100);" @click='popMark()'>下载报告</a> | |||
| </span> | |||
| </a> | |||
| @@ -335,7 +335,7 @@ | |||
| } | |||
| }; | |||
| this.$axios.get('../tool/query_user_static_page',{ | |||
| this.$axios.get('../api/v1/query_user_static_page',{ | |||
| params:this.params | |||
| }).then((res)=>{ | |||
| this.tableData = res.data.data | |||