| @@ -920,7 +920,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, | |||
| CountDate = time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 0, 1, 0, 0, currentTimeNow.Location()) | |||
| } | |||
| DataDate := startTime.Format("2006-01-02") | |||
| DataDate := CountDate.Format("2006-01-02") | |||
| CodeMergeCountMap := queryPullRequest(start_unix, end_unix) | |||
| CommitCountMap := queryCommitAction(start_unix, end_unix, 5) | |||
| IssueCountMap := queryCreateIssue(start_unix, end_unix) | |||
| @@ -1103,6 +1103,7 @@ func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, userA | |||
| ",activate_regist_user=" + fmt.Sprint(useMetrics.ActivateRegistUser) + | |||
| ",not_activate_regist_user=" + fmt.Sprint(useMetrics.CurrentDayRegistUser-useMetrics.ActivateRegistUser) + | |||
| ",current_day_regist_user=" + fmt.Sprint(useMetrics.CurrentDayRegistUser) + | |||
| ",data_date='" + time.Unix(key, 0).Format("2006-01-02") + "'" + | |||
| " where count_date=" + fmt.Sprint(key) | |||
| statictisSess.Exec(updateSql) | |||
| @@ -636,6 +636,7 @@ func CloudBrainTrainJobShow(ctx *context.Context) { | |||
| func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.JobType) { | |||
| ctx.Data["PageIsCloudBrain"] = true | |||
| debugListType := ctx.Query("debugListType") | |||
| cloudbrain.InitSpecialPool() | |||
| var task *models.Cloudbrain | |||
| var err error | |||
| @@ -647,22 +648,22 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| if err != nil { | |||
| log.Info("error:" + err.Error()) | |||
| ctx.Data["error"] = err.Error() | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| result, err := cloudbrain.GetJob(task.JobID) | |||
| if err != nil { | |||
| log.Info("error:" + err.Error()) | |||
| ctx.Data["error"] = err.Error() | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| hasSpec := false | |||
| if task.JobType == string(models.JobTypeTrain) { | |||
| if cloudbrain.TrainResourceSpecs == nil { | |||
| json.Unmarshal([]byte(setting.TrainResourceSpecs), &cloudbrain.TrainResourceSpecs) | |||
| } | |||
| hasSpec := false | |||
| for _, tmp := range cloudbrain.TrainResourceSpecs.ResourceSpec { | |||
| if tmp.Id == task.ResourceSpecId { | |||
| hasSpec = true | |||
| @@ -670,24 +671,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| ctx.Data["CpuNum"] = tmp.CpuNum | |||
| ctx.Data["MemMiB"] = tmp.MemMiB | |||
| ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB | |||
| } | |||
| } | |||
| if !hasSpec && cloudbrain.SpecialPools != nil { | |||
| for _, specialPool := range cloudbrain.SpecialPools.Pools { | |||
| if specialPool.ResourceSpec != nil { | |||
| for _, spec := range specialPool.ResourceSpec { | |||
| if task.ResourceSpecId == spec.Id { | |||
| ctx.Data["GpuNum"] = spec.GpuNum | |||
| ctx.Data["CpuNum"] = spec.CpuNum | |||
| ctx.Data["MemMiB"] = spec.MemMiB | |||
| ctx.Data["ShareMemMiB"] = spec.ShareMemMiB | |||
| break | |||
| } | |||
| } | |||
| } | |||
| break | |||
| } | |||
| } | |||
| @@ -697,10 +681,12 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| } | |||
| for _, tmp := range cloudbrain.InferenceResourceSpecs.ResourceSpec { | |||
| if tmp.Id == task.ResourceSpecId { | |||
| hasSpec = true | |||
| ctx.Data["GpuNum"] = tmp.GpuNum | |||
| ctx.Data["CpuNum"] = tmp.CpuNum | |||
| ctx.Data["MemMiB"] = tmp.MemMiB | |||
| ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB | |||
| break | |||
| } | |||
| } | |||
| } else { | |||
| @@ -709,10 +695,32 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| } | |||
| for _, tmp := range cloudbrain.ResourceSpecs.ResourceSpec { | |||
| if tmp.Id == task.ResourceSpecId { | |||
| hasSpec = true | |||
| ctx.Data["GpuNum"] = tmp.GpuNum | |||
| ctx.Data["CpuNum"] = tmp.CpuNum | |||
| ctx.Data["MemMiB"] = tmp.MemMiB | |||
| ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB | |||
| break | |||
| } | |||
| } | |||
| } | |||
| if !hasSpec && cloudbrain.SpecialPools != nil { | |||
| for _, specialPool := range cloudbrain.SpecialPools.Pools { | |||
| if specialPool.ResourceSpec != nil { | |||
| for _, spec := range specialPool.ResourceSpec { | |||
| if task.ResourceSpecId == spec.Id { | |||
| ctx.Data["GpuNum"] = spec.GpuNum | |||
| ctx.Data["CpuNum"] = spec.CpuNum | |||
| ctx.Data["MemMiB"] = spec.MemMiB | |||
| ctx.Data["ShareMemMiB"] = spec.ShareMemMiB | |||
| break | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -731,14 +739,6 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| ctx.Data["resource_type"] = resourceType.Value | |||
| } | |||
| } | |||
| for _, specialPool := range cloudbrain.SpecialPools.Pools { | |||
| for _, resourceType := range specialPool.Pool { | |||
| if resourceType.Queue == jobRes.Config.GpuType { | |||
| ctx.Data["resource_type"] = resourceType.Value | |||
| } | |||
| } | |||
| } | |||
| } else if task.JobType == string(models.JobTypeInference) { | |||
| if inferenceGpuInfos == nil { | |||
| @@ -770,6 +770,16 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| } | |||
| } | |||
| } | |||
| if cloudbrain.SpecialPools != nil { | |||
| for _, specialPool := range cloudbrain.SpecialPools.Pools { | |||
| for _, resourceType := range specialPool.Pool { | |||
| if resourceType.Queue == jobRes.Config.GpuType { | |||
| ctx.Data["resource_type"] = resourceType.Value | |||
| } | |||
| } | |||
| } | |||
| } | |||
| taskRoles := jobRes.TaskRoles | |||
| taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | |||
| ctx.Data["taskRes"] = taskRes | |||
| @@ -895,6 +905,20 @@ func CloudBrainCommitImageShow(ctx *context.Context) { | |||
| ctx.HTML(200, tplCloudBrainImageSubmit) | |||
| } | |||
| func GetImage(ctx *context.Context) { | |||
| var ID = ctx.Params(":id") | |||
| id, _ := strconv.ParseInt(ID, 10, 64) | |||
| image, err := models.GetImageByID(id) | |||
| if err != nil { | |||
| log.Error("GetImageByID failed:%v", err.Error()) | |||
| ctx.JSON(http.StatusNotFound, nil) | |||
| } | |||
| ctx.JSON(http.StatusOK, image) | |||
| } | |||
| func CloudBrainImageEdit(ctx *context.Context) { | |||
| ctx.Data["PageIsImageEdit"] = true | |||
| ctx.Data["PageFrom"] = ctx.Params(":from") | |||
| @@ -626,7 +626,7 @@ func GrampusTrainJobShow(ctx *context.Context) { | |||
| task, err := models.GetCloudbrainByJobIDWithDeleted(ctx.Params(":jobid")) | |||
| if err != nil { | |||
| log.Error("GetCloudbrainByJobID failed:" + err.Error()) | |||
| ctx.ServerError("system error", err) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| @@ -634,8 +634,8 @@ func GrampusTrainJobShow(ctx *context.Context) { | |||
| result, err := grampus.GetJob(task.JobID) | |||
| if err != nil { | |||
| log.Error("GetJob failed:" + err.Error()) | |||
| //ctx.ServerError("GetJob failed", err) | |||
| //return | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| if result != nil { | |||
| @@ -258,8 +258,8 @@ func NotebookShow(ctx *context.Context) { | |||
| var ID = ctx.Params(":id") | |||
| task, err := models.GetCloudbrainByIDWithDeleted(ID) | |||
| if err != nil { | |||
| ctx.Data["error"] = err.Error() | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) | |||
| log.Error("GET job error", err.Error()) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| @@ -1656,8 +1656,12 @@ func TrainJobShow(ctx *context.Context) { | |||
| }) | |||
| if err != nil { | |||
| log.Error("GetVersionListTasks(%s) failed:%v", job.DisplayJobName, err.Error()) | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) | |||
| log.Error("GetVersionListTasks(%s) failed:%v", id, err.Error()) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| if len(VersionListTasks) == 0 { | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| //设置权限 | |||
| @@ -2246,7 +2250,7 @@ func InferenceJobShow(ctx *context.Context) { | |||
| task, err := models.GetCloudbrainByID(id) | |||
| if err != nil { | |||
| log.Error("GetCloudbrainByID(%s) failed:%v", id, err.Error()) | |||
| ctx.ServerError("GetCloudbrainByID failed", err) | |||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||
| return | |||
| } | |||
| //设置权限 | |||
| @@ -1016,6 +1016,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
| }, context.RepoAssignment(), context.RepoMustNotBeArchived(), reqRepoAdmin) | |||
| m.Group("/image/:id", func() { | |||
| m.Get("", repo.GetImage) | |||
| m.Get("/:from", cloudbrain.AdminOrImageCreaterRight, repo.CloudBrainImageEdit) | |||
| m.Post("", cloudbrain.AdminOrImageCreaterRight, bindIgnErr(auth.EditImageCloudBrainForm{}), repo.CloudBrainImageEditPost) | |||
| m.Delete("", cloudbrain.AdminOrImageCreaterRight, repo.CloudBrainImageDelete) | |||
| @@ -48,7 +48,7 @@ | |||
| <button class="ui green button"> | |||
| {{.i18n.Tr "org.create_org"}} | |||
| </button> | |||
| <a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a> | |||
| <a class="ui button" href="javascript:history.go(-1)">{{.i18n.Tr "cancel"}}</a> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -176,7 +176,7 @@ | |||
| <button class="ui green button" id="submit_reponame"> | |||
| {{.i18n.Tr "repo.create_repo"}} | |||
| </button> | |||
| <a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a> | |||
| <a class="ui button" href="javascript:history.go(-1)">{{.i18n.Tr "cancel"}}</a> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -102,7 +102,7 @@ | |||
| <button class="ui green button" id="submit_reponame"> | |||
| {{.i18n.Tr "repo.migrate_repo"}} | |||
| </button> | |||
| <a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a> | |||
| <a class="ui button" href="javascript:history.go(-1)">{{.i18n.Tr "cancel"}}</a> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -168,8 +168,8 @@ export default async function initCloudrainSow() { | |||
| let downloadFlag = $(this).data("download-flag") || ""; | |||
| let gpuFlag = $(this).data("gpu-flag") || ""; | |||
| let version_name = $(this).data("version"); | |||
| let parents = $(this).data("parents") || ""; | |||
| let filename = $(this).data("filename") || ""; | |||
| let parents = $(this).data("parents"); | |||
| let filename = $(this).data("filename"); | |||
| let init = $(this).data("init") || ""; | |||
| let path = $(this).data("path"); | |||
| let url = `/api/v1/repos${path}?version_name=${version_name}&parentDir=${parents}`; | |||
| @@ -189,7 +189,7 @@ export default async function initCloudrainSow() { | |||
| htmlBread += "<div class='divider'> / </div>"; | |||
| $(`#file_breadcrumb${version_name}`).append(htmlBread); | |||
| } else { | |||
| renderBrend(path, version_name, parents, filename, init); | |||
| renderBrend(path, version_name, parents, filename, init, downloadFlag); | |||
| } | |||
| }).fail(function (err) { | |||
| console.log(err, version_name); | |||
| @@ -217,7 +217,14 @@ export default async function initCloudrainSow() { | |||
| size = size.toFixed(0); //保留的小数位数 | |||
| return size + unitArr[index]; | |||
| } | |||
| function renderBrend(path, version_name, parents, filename, init) { | |||
| function renderBrend( | |||
| path, | |||
| version_name, | |||
| parents, | |||
| filename, | |||
| init, | |||
| downloadFlag | |||
| ) { | |||
| if (init == "folder") { | |||
| let htmlBrend = ""; | |||
| let sectionName = $( | |||
| @@ -227,11 +234,11 @@ export default async function initCloudrainSow() { | |||
| let filename1 = $(`input[name=modelback${version_name}]`).val(); | |||
| if (parents1 === "") { | |||
| $(`#file_breadcrumb${version_name} .active.section`).replaceWith( | |||
| `<a class='section load-model-file' data-path='${path}' data-version='${version_name}' data-parents='${parents1}' data-filename='' data-init='init'>${sectionName}</a>` | |||
| `<a class='section load-model-file' data-download-flag='${downloadFlag}' data-path='${path}' data-version='${version_name}' data-parents='${parents1}' data-filename='' data-init='init'>${sectionName}</a>` | |||
| ); | |||
| } else { | |||
| $(`#file_breadcrumb${version_name} .active.section`).replaceWith( | |||
| `<a class='section load-model-file' data-path='${path}' data-version='${version_name}' data-parents='${parents1}' data-filename='${filename1}'>${sectionName}</a>` | |||
| `<a class='section load-model-file' data-download-flag='${downloadFlag}' data-path='${path}' data-version='${version_name}' data-parents='${parents1}' data-filename='${filename1}'>${sectionName}</a>` | |||
| ); | |||
| } | |||
| @@ -272,7 +279,7 @@ export default async function initCloudrainSow() { | |||
| html += "<span class='octicon octicon-file-directory'>"; | |||
| html += "</span>"; | |||
| if (data.Dirs[i].IsDir) { | |||
| html += `<a class='load-model-file' data-path='${path}' data-version='${version_name}' data-parents='${data.Dirs[i].ParenDir}' data-filename='${data.Dirs[i].FileName}' data-init='folder'>`; | |||
| html += `<a class='load-model-file' data-download-flag='${downloadFlag}' data-path='${path}' data-version='${version_name}' data-parents='${data.Dirs[i].ParenDir}' data-filename='${data.Dirs[i].FileName}' data-init='folder'>`; | |||
| html += | |||
| "<span class='fitted'><i class='folder icon' width='16' height='16' aria-hidden='true'></i>" + | |||
| data.Dirs[i].FileName + | |||