Browse Source

Merge branch 'V20220110' into fix-1215

pull/1240/head
zhoupzh 3 years ago
parent
commit
6cad5d93a5
7 changed files with 122 additions and 45 deletions
  1. +10
    -3
      models/cloudbrain.go
  2. +3
    -1
      models/repo_watch.go
  3. +52
    -8
      routers/repo/blame.go
  4. +6
    -7
      routers/repo/modelarts.go
  5. +4
    -4
      routers/routes/routes.go
  6. +40
    -22
      templates/org/select_pro.tmpl
  7. +7
    -0
      templates/repo/debugjob/index.tmpl

+ 10
- 3
models/cloudbrain.go View File

@@ -210,6 +210,7 @@ type CloudbrainsOptions struct {
JobType string
VersionName string
IsLatestVersion string
JobTypeNot bool
}

type TaskPod struct {
@@ -894,9 +895,15 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) {
}

if (opts.JobType) != "" {
cond = cond.And(
builder.Eq{"cloudbrain.job_type": opts.JobType},
)
if opts.JobTypeNot {
cond = cond.And(
builder.Neq{"cloudbrain.job_type": opts.JobType},
)
} else {
cond = cond.And(
builder.Eq{"cloudbrain.job_type": opts.JobType},
)
}
}

if (opts.IsLatestVersion) != "" {


+ 3
- 1
models/repo_watch.go View File

@@ -286,7 +286,9 @@ func NotifyWatchers(actions ...*Action) error {

func producer(actions ...*Action) {
for _, action := range actions {
ActionChan <- action
if !action.IsPrivate{
ActionChan <- action
}
}
}



+ 52
- 8
routers/repo/blame.go View File

@@ -6,13 +6,6 @@ package repo

import (
"bytes"
"container/list"
"fmt"
"html"
gotemplate "html/template"
"net/url"
"strings"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
@@ -22,6 +15,12 @@ import (
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
"container/list"
"fmt"
"html"
gotemplate "html/template"
"net/url"
"strings"
)

const (
@@ -35,7 +34,52 @@ func RefBlame(ctx *context.Context) {
ctx.NotFound("Blame FileName", nil)
return
}

//get repo contributors info
contributors, err := git.GetContributors(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName)
if err == nil && contributors != nil {
var contributorInfos []*ContributorInfo
contributorInfoHash := make(map[string]*ContributorInfo)
count := 0
for _, c := range contributors {
if count >= 25 {
continue
}
if strings.Compare(c.Email, "") == 0 {
continue
}
// get user info from committer email
user, err := models.GetUserByActivateEmail(c.Email)
if err == nil {
// committer is system user, get info through user's primary email
if existedContributorInfo, ok := contributorInfoHash[user.Email]; ok {
// existed: same primary email, different committer name
existedContributorInfo.CommitCnt += c.CommitCnt
} else {
// new committer info
var newContributor = &ContributorInfo{
user, user.RelAvatarLink(), user.Name, user.Email, c.CommitCnt,
}
count++
contributorInfos = append(contributorInfos, newContributor)
contributorInfoHash[user.Email] = newContributor
}
} else {
// committer is not system user
if existedContributorInfo, ok := contributorInfoHash[c.Email]; ok {
// existed: same primary email, different committer name
existedContributorInfo.CommitCnt += c.CommitCnt
} else {
var newContributor = &ContributorInfo{
user, "", "", c.Email, c.CommitCnt,
}
count++
contributorInfos = append(contributorInfos, newContributor)
contributorInfoHash[c.Email] = newContributor
}
}
}
ctx.Data["ContributorInfo"] = contributorInfos
}
userName := ctx.Repo.Owner.Name
repoName := ctx.Repo.Repository.Name
commitID := ctx.Repo.CommitID


+ 6
- 7
routers/repo/modelarts.go View File

@@ -49,12 +49,9 @@ func DebugJobIndex(ctx *context.Context) {
page = 1
}
debugType := modelarts.DebugType
jobType := string(models.JobTypeDebug)
if debugListType == models.GPUResource {
debugType = models.TypeCloudBrainOne
jobType = ""
}
if debugListType == models.NPUResource {
} else if debugListType == models.NPUResource {
debugType = models.TypeCloudBrainTwo
}

@@ -63,9 +60,10 @@ func DebugJobIndex(ctx *context.Context) {
Page: page,
PageSize: setting.UI.IssuePagingNum,
},
RepoID: repo.ID,
Type: debugType,
JobType: jobType,
RepoID: repo.ID,
Type: debugType,
JobTypeNot: true,
JobType: string(models.JobTypeTrain),
})
if err != nil {
ctx.ServerError("Get debugjob faild:", err)
@@ -371,6 +369,7 @@ func TrainJobIndex(ctx *context.Context) {
},
RepoID: repo.ID,
Type: models.TypeCloudBrainTwo,
JobTypeNot: false,
JobType: string(models.JobTypeTrain),
IsLatestVersion: modelarts.IsLatestVersion,
})


+ 4
- 4
routers/routes/routes.go View File

@@ -969,13 +969,13 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/:jobid", func() {
m.Get("", reqRepoCloudBrainReader, repo.CloudBrainShow)
m.Get("/debug", cloudbrain.AdminOrJobCreaterRight, repo.CloudBrainDebug)
m.Post("/commit_image", cloudbrain.AdminOrOwnerOrJobCreaterRight, bindIgnErr(auth.CommitImageCloudBrainForm{}), repo.CloudBrainCommitImage)
m.Post("/commit_image", cloudbrain.AdminOrJobCreaterRight, bindIgnErr(auth.CommitImageCloudBrainForm{}), repo.CloudBrainCommitImage)
m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop)
m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainDel)
m.Post("/restart", reqRepoCloudBrainWriter, repo.CloudBrainRestart)
m.Post("/restart", cloudbrain.AdminOrJobCreaterRight, repo.CloudBrainRestart)
m.Get("/rate", reqRepoCloudBrainReader, repo.GetRate)
m.Get("/models", reqRepoCloudBrainReader, repo.CloudBrainShowModels)
m.Get("/download_model", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainDownloadModel)
m.Get("/download_model", cloudbrain.AdminOrJobCreaterRight, repo.CloudBrainDownloadModel)
})
m.Get("/create", reqRepoCloudBrainWriter, repo.CloudBrainNew)
m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateCloudBrainForm{}), repo.CloudBrainCreate)
@@ -1021,7 +1021,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("", reqRepoCloudBrainReader, repo.TrainJobShow)
m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.TrainJobStop)
m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.TrainJobDel)
m.Get("/model_download", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.ModelDownload)
m.Get("/model_download", cloudbrain.AdminOrJobCreaterRight, repo.ModelDownload)
m.Get("/create_version", cloudbrain.AdminOrJobCreaterRight, repo.TrainJobNewVersion)
m.Post("/create_version", cloudbrain.AdminOrJobCreaterRight, bindIgnErr(auth.CreateModelArtsTrainJobForm{}), repo.TrainJobCreateVersion)
})


+ 40
- 22
templates/org/select_pro.tmpl View File

@@ -13,7 +13,8 @@
.header_card{
/* color:#003A8C !important; */
color:#0366D6 !important;
margin: 10px 0;
margin: 10px 0 0px 0;
height: 25px;
}
.marg{
margin: 0 5px !important;
@@ -28,6 +29,7 @@
}
.descript_height{
color: #101010 !important;
margin: 10px 0;
height: 40px !important;
word-break:break-all;
line-height: 20px;
@@ -44,9 +46,23 @@
.full_height{
height: 100%;
}
.omit{
overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
/deep/ ui.checkbox input[type=checkbox]::after{
border: 1px solid #0366D6 !important;
}
.nowrap-2 {
/* height: 2.837em; */
/* line-height: 1.4285em; */
overflow: hidden;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}


</style>
<div class="ui stackable grid">
<div style="width: 100%;margin:15px 0;">
@@ -69,25 +85,30 @@
{{ range .RepoList}}
<div class="card" >
<div class="extra full_height" >
<div class=" header ">
<a class="header_card" href="{{.Link}}"> {{.Name}}</a>
<div class="extra full_height cor" >
<div class=" header header_card omit" >
<a class="header_card image poping up " href="{{.Link}}" data-content="{{.Name}}" data-position="top left" data-variation="tiny inverted"> {{.Name}}</a>
</div>
<div class='content descript_height'>
<div class='content descript_height nowrap-2'>
{{.Description}}
</div>
<div class="content tags_height" style="margin-top: 5px;">
{{if .Topics }}
<div class=" ui tags ">
<div class="content " >
{{if .Topics }}
<div class=" tags " style="position: relative;">
{{range .Topics}}
{{if ne . "" }}<a href="{{AppSubUrl}}/explore/repos?q={{.}}&topic={{$.Topic}}"><div class="ui small label topic">{{.}}</div></a>{{end}}
{{if ne . "" }}<a style="max-width:100%;margin: 5px 0;display:inline-flex;" href="{{AppSubUrl}}/explore/repos?q={{.}}&topic={{$.Topic}}" ><span class="ui small label topic omit" >{{.}}</span></a>{{end}}
{{end}}
</div>
{{end}}
</div>
{{end}}
</div>
</div>
<div class=" extra " style="color:#888888;border-top: none !important">
<div class="ui mini right compact marg" >
<a class="item marg ">
{{svg "octicon-eye" 16}} {{.NumWatches}}
@@ -100,9 +121,6 @@
</a>
</div>

</div>
</div>
{{end}}
@@ -133,7 +151,7 @@
</div>
<p id='recommend'></p>
<div class="inline field" style="margin-left: 30%;">
<div class="inline field" style="margin-left: 37%;">
<div class="actions">
<button id="submitId" type="button" class="ui create_train_job green deny button" onclick="saveSeletedPro(1)">
{{.i18n.Tr "explore.save"}}
@@ -171,7 +189,7 @@

$.ajax({
type:"GET",
url:"/org/{{.Org.DisplayName}}/org_tag/repo_list?tagId="+typeTag,
url:"/org/{{.Org.Name}}/org_tag/repo_list?tagId="+typeTag,
dataType:"json",
async:false,
success:function(json){
@@ -179,7 +197,7 @@
var n_length = data.length
pro_html = getHTML(data)
$("#org_list").append(pro_html)
console.log('原始',data)
// console.log('原始',data)
checkedNum(0)
}
});
@@ -189,11 +207,11 @@
for (let i=0;i<data.length;i++){
if (data[i].Selected==true){
console.log("data[i]:",data[i])
pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" id = " ${i}" checked="" onclick="checkedNum(${i})" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected=${data[i].Selected} > <label> ${data[i].RepoName} </label></div>`
pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" id = " ${i}" checked="" onclick="checkedNum(${i})" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected=${data[i].Selected} > <label class='omit image poping up' data-content=${data[i].RepoName}  data-position="top left " data-variation="mini"> ${data[i].RepoName}</label></div>`
pro_html += '</div>'
}
else{
pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" id = "${i}" onclick="checkedNum(${i})" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected= ${data[i].Selected}> <label> ${data[i].RepoName} </label></div>`
pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" id = "${i}" onclick="checkedNum(${i})" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected= ${data[i].Selected}> <label class='omit image poping up' data-content=${data[i].RepoName}  data-position="top left " data-variation="mini"> ${data[i].RepoName} </label></div>`
pro_html += '</div>'
}
}
@@ -214,7 +232,7 @@
// console.log("数据:",saveData)
$.ajax({
type:"POST",
url:"/org/{{.Org.DisplayName}}/org_tag/repo_submit?tagId="+typeTag,
url:"/org/{{.Org.Name}}/org_tag/repo_submit?tagId="+typeTag,
contentType:'application/json',
dataType:"json",
async:false,


+ 7
- 0
templates/repo/debugjob/index.tmpl View File

@@ -402,6 +402,13 @@
<a class="ui basic disabled button">{{$.i18n.Tr "repo.download"}}</a>
{{end}}
</div>
{{if and (ne .JobType "DEBUG") (eq .Cloudbrain.Type 0)}}
<div class="item" style="padding: 0 !important;">
<a class="ui basic blue button" href="{{$.RepoLink}}/cloudbrain/{{.JobID}}/rate" target="_blank">
评分
</a>
</div>
{{end}}
</div>
</div>


Loading…
Cancel
Save