| @@ -388,7 +388,7 @@ type JobResultPayload struct { | |||
| AppProgress string `json:"appProgress"` | |||
| AppTrackingURL string `json:"appTrackingUrl"` | |||
| AppLaunchedTime int64 `json:"appLaunchedTime"` | |||
| AppCompletedTime int64 `json:"appCompletedTime"` | |||
| AppCompletedTime interface{} `json:"appCompletedTime"` | |||
| AppExitCode int `json:"appExitCode"` | |||
| AppExitDiagnostics string `json:"appExitDiagnostics"` | |||
| AppExitType interface{} `json:"appExitType"` | |||
| @@ -1370,6 +1370,16 @@ func getRepoCloudBrain(cb *Cloudbrain) (*Cloudbrain, error) { | |||
| return cb, nil | |||
| } | |||
| func getRepoCloudBrainWithDeleted(cb *Cloudbrain) (*Cloudbrain, error) { | |||
| has, err := x.Unscoped().Get(cb) | |||
| if err != nil { | |||
| return nil, err | |||
| } else if !has { | |||
| return nil, ErrJobNotExist{} | |||
| } | |||
| return cb, nil | |||
| } | |||
| func GetRepoCloudBrainByJobID(repoID int64, jobID string) (*Cloudbrain, error) { | |||
| cb := &Cloudbrain{JobID: jobID, RepoID: repoID} | |||
| return getRepoCloudBrain(cb) | |||
| @@ -1386,6 +1396,12 @@ func GetCloudbrainByID(id string) (*Cloudbrain, error) { | |||
| return getRepoCloudBrain(cb) | |||
| } | |||
| func GetCloudbrainByIDWithDeleted(id string) (*Cloudbrain, error) { | |||
| idInt64, _ := strconv.ParseInt(id, 10, 64) | |||
| cb := &Cloudbrain{ID: idInt64} | |||
| return getRepoCloudBrainWithDeleted(cb) | |||
| } | |||
| func GetCloudbrainByJobIDAndVersionName(jobID string, versionName string) (*Cloudbrain, error) { | |||
| cb := &Cloudbrain{JobID: jobID, VersionName: versionName} | |||
| return getRepoCloudBrain(cb) | |||
| @@ -139,20 +139,7 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { | |||
| var cond = builder.NewCond() | |||
| cond = cond.And(builder.Neq{"dataset.status": DatasetStatusDeleted}) | |||
| if len(opts.Keyword) > 0 { | |||
| cond = cond.And(builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) | |||
| } | |||
| if len(opts.Category) > 0 { | |||
| cond = cond.And(builder.Eq{"dataset.category": opts.Category}) | |||
| } | |||
| if len(opts.Task) > 0 { | |||
| cond = cond.And(builder.Eq{"dataset.task": opts.Task}) | |||
| } | |||
| if len(opts.License) > 0 { | |||
| cond = cond.And(builder.Eq{"dataset.license": opts.License}) | |||
| } | |||
| cond = generateFilterCond(opts, cond) | |||
| if opts.RepoID > 0 { | |||
| cond = cond.And(builder.Eq{"dataset.repo_id": opts.RepoID}) | |||
| @@ -162,14 +149,12 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { | |||
| cond = cond.And(builder.Eq{"dataset.status": DatasetStatusPublic}) | |||
| cond = cond.And(builder.Eq{"attachment.is_private": false}) | |||
| if opts.OwnerID > 0 { | |||
| if len(opts.Keyword) == 0 { | |||
| cond = cond.Or(builder.Eq{"repository.owner_id": opts.OwnerID}) | |||
| } else { | |||
| subCon := builder.NewCond() | |||
| subCon = subCon.And(builder.Eq{"repository.owner_id": opts.OwnerID}, builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) | |||
| cond = cond.Or(subCon) | |||
| } | |||
| subCon := builder.NewCond() | |||
| subCon = subCon.And(builder.Eq{"repository.owner_id": opts.OwnerID}) | |||
| subCon = generateFilterCond(opts, subCon) | |||
| cond = cond.Or(subCon) | |||
| } | |||
| } else if opts.OwnerID > 0 { | |||
| cond = cond.And(builder.Eq{"repository.owner_id": opts.OwnerID}) | |||
| @@ -182,6 +167,25 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { | |||
| return cond | |||
| } | |||
| func generateFilterCond(opts *SearchDatasetOptions, cond builder.Cond) builder.Cond { | |||
| if len(opts.Keyword) > 0 { | |||
| cond = cond.And(builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) | |||
| } | |||
| if len(opts.Category) > 0 { | |||
| cond = cond.And(builder.Eq{"dataset.category": opts.Category}) | |||
| } | |||
| if len(opts.Task) > 0 { | |||
| cond = cond.And(builder.Eq{"dataset.task": opts.Task}) | |||
| } | |||
| if len(opts.License) > 0 { | |||
| cond = cond.And(builder.Eq{"dataset.license": opts.License}) | |||
| } | |||
| return cond | |||
| } | |||
| func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (DatasetList, int64, error) { | |||
| if opts.Page <= 0 { | |||
| opts.Page = 1 | |||
| @@ -348,7 +352,7 @@ func GetDatasetByRepo(repo *Repository) (*Dataset, error) { | |||
| if has { | |||
| return dataset, nil | |||
| } else { | |||
| return nil, errors.New("Not Found") | |||
| return nil, ErrNotExist{repo.ID} | |||
| } | |||
| } | |||
| @@ -1607,14 +1607,16 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e | |||
| } | |||
| dataset, err := GetDatasetByRepo(repo) | |||
| if err != nil { | |||
| if err != nil && !IsErrNotExist(err) { | |||
| return err | |||
| } | |||
| _, err = e.Where("dataset_id = ?", dataset.ID).Cols("is_private").Update(&Attachment{ | |||
| IsPrivate: true, | |||
| }) | |||
| if err != nil { | |||
| return err | |||
| if dataset != nil { | |||
| _, err = e.Where("dataset_id = ?", dataset.ID).Cols("is_private").Update(&Attachment{ | |||
| IsPrivate: true, | |||
| }) | |||
| if err != nil { | |||
| return err | |||
| } | |||
| } | |||
| } else { | |||
| @@ -401,18 +401,22 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| if jobType == models.JobTypeTrain { | |||
| task, err = models.GetCloudbrainByJobID(ctx.Params(":jobid")) | |||
| } else { | |||
| task, err = models.GetCloudbrainByID(ctx.Params(":id")) | |||
| task, err = models.GetCloudbrainByIDWithDeleted(ctx.Params(":id")) | |||
| } | |||
| if err != nil { | |||
| log.Info("error:" + err.Error()) | |||
| ctx.Data["error"] = err.Error() | |||
| return | |||
| } | |||
| result, err := cloudbrain.GetJob(task.JobID) | |||
| if err != nil { | |||
| log.Info("error:" + err.Error()) | |||
| ctx.Data["error"] = err.Error() | |||
| return | |||
| } | |||
| if result != nil { | |||
| jobRes, _ := models.ConvertToJobResultPayload(result.Payload) | |||
| jobRes.Resource.Memory = strings.ReplaceAll(jobRes.Resource.Memory, "Mi", "MB") | |||
| @@ -427,6 +431,15 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| ctx.Data["resource_type"] = resourceType.Value | |||
| } | |||
| } | |||
| } else { | |||
| if gpuInfos == nil { | |||
| json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) | |||
| } | |||
| for _, resourceType := range gpuInfos.GpuInfo { | |||
| if resourceType.Queue == jobRes.Config.GpuType { | |||
| ctx.Data["resource_type"] = resourceType.Value | |||
| } | |||
| } | |||
| } | |||
| taskRoles := jobRes.TaskRoles | |||
| if jobRes.JobStatus.State != string(models.JobFailed) { | |||
| @@ -437,9 +450,15 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| task.ContainerID = taskRes.TaskStatuses[0].ContainerID | |||
| task.ContainerIp = taskRes.TaskStatuses[0].ContainerIP | |||
| models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| ctx.Data["error"] = err.Error() | |||
| if task.DeletedAt.IsZero() { //normal record | |||
| err = models.UpdateJob(task) | |||
| if err != nil { | |||
| ctx.Data["error"] = err.Error() | |||
| return | |||
| } | |||
| } else { //deleted record | |||
| } | |||
| } else { | |||
| task.Status = jobRes.JobStatus.State | |||
| @@ -456,7 +475,9 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo | |||
| ctx.Data["result"] = jobRes | |||
| } else { | |||
| log.Info("error:" + err.Error()) | |||
| return | |||
| } | |||
| user, err := models.GetUserByID(task.UserID) | |||
| if err == nil { | |||
| task.User = user | |||
| @@ -247,7 +247,11 @@ func renderDirectory(ctx *context.Context, treeLink string) { | |||
| ctx.Data["ReadmeInList"] = true | |||
| ctx.Data["ReadmeExist"] = true | |||
| ctx.Data["FileIsSymlink"] = readmeFile.isSymlink | |||
| ctx.Data["ReadmeName"] = readmeFile.name | |||
| if ctx.Repo.TreePath == "" { | |||
| ctx.Data["ReadmeRelativePath"] = readmeFile.name | |||
| } else { | |||
| ctx.Data["ReadmeRelativePath"] = ctx.Repo.TreePath + "/" + readmeFile.name | |||
| } | |||
| if ctx.Repo.CanEnableEditor() { | |||
| ctx.Data["CanEditFile"] = true | |||
| @@ -579,11 +583,11 @@ func safeURL(address string) string { | |||
| } | |||
| type ContributorInfo struct { | |||
| UserInfo *models.User // nil for contributor who is not a registered user | |||
| RelAvatarLink string `json:"rel_avatar_link"` | |||
| UserName string `json:"user_name"` | |||
| Email string `json:"email"` | |||
| CommitCnt int `json:"commit_cnt"` | |||
| UserInfo *models.User // nil for contributor who is not a registered user | |||
| RelAvatarLink string `json:"rel_avatar_link"` | |||
| UserName string `json:"user_name"` | |||
| Email string `json:"email"` | |||
| CommitCnt int `json:"commit_cnt"` | |||
| } | |||
| type GetContributorsInfo struct { | |||
| @@ -642,7 +646,7 @@ func Home(ctx *context.Context) { | |||
| existedContributorInfo.CommitCnt += c.CommitCnt | |||
| } else { | |||
| var newContributor = &ContributorInfo{ | |||
| user, "", "",c.Email, c.CommitCnt, | |||
| user, "", "", c.Email, c.CommitCnt, | |||
| } | |||
| count++ | |||
| contributorInfos = append(contributorInfos, newContributor) | |||
| @@ -839,7 +843,7 @@ func renderCode(ctx *context.Context) { | |||
| compareInfo, err = baseGitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName, ctx.Repo.Repository.BaseRepo.DefaultBranch) | |||
| ctx.Data["UpstreamSameBranchName"] = false | |||
| } | |||
| if err==nil && compareInfo != nil { | |||
| if err == nil && compareInfo != nil { | |||
| if compareInfo.Commits != nil { | |||
| log.Info("compareInfoCommits数量:%d", compareInfo.Commits.Len()) | |||
| ctx.Data["FetchUpstreamCnt"] = compareInfo.Commits.Len() | |||
| @@ -950,7 +954,7 @@ func ContributorsAPI(ctx *context.Context) { | |||
| } else { | |||
| // new committer info | |||
| var newContributor = &ContributorInfo{ | |||
| user, user.RelAvatarLink(),user.Name, user.Email,c.CommitCnt, | |||
| user, user.RelAvatarLink(), user.Name, user.Email, c.CommitCnt, | |||
| } | |||
| count++ | |||
| contributorInfos = append(contributorInfos, newContributor) | |||
| @@ -963,7 +967,7 @@ func ContributorsAPI(ctx *context.Context) { | |||
| existedContributorInfo.CommitCnt += c.CommitCnt | |||
| } else { | |||
| var newContributor = &ContributorInfo{ | |||
| user, "", "",c.Email,c.CommitCnt, | |||
| user, "", "", c.Email, c.CommitCnt, | |||
| } | |||
| count++ | |||
| contributorInfos = append(contributorInfos, newContributor) | |||
| @@ -40,7 +40,7 @@ | |||
| <div class="ui right file-actions"> | |||
| {{if .Repository.CanEnableEditor}} | |||
| {{if .CanEditFile}} | |||
| <a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .ReadmeName}}"><span class="btn-octicon poping up" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span></a> | |||
| <a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .ReadmeRelativePath}}"><span class="btn-octicon poping up" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span></a> | |||
| {{else}} | |||
| <span class="btn-octicon poping up disabled" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span> | |||
| {{end}} | |||
| @@ -48,7 +48,7 @@ | |||
| </div> | |||
| </div> | |||
| {{end}} | |||
| {{if not .ReadmeInList}} | |||
| <div class="file-header-right"> | |||
| <div class="ui right file-actions"> | |||