Browse Source

merge

tags/V1.22.3.1^2
liuzx 3 years ago
parent
commit
6f26232c0a
17 changed files with 183 additions and 52 deletions
  1. +1
    -1
      custom/public/css/git.openi.css
  2. +8
    -5
      models/cloudbrain.go
  3. +2
    -2
      models/org.go
  4. +13
    -0
      models/topic.go
  5. +2
    -1
      modules/modelarts/resty.go
  6. +6
    -0
      modules/repository/fork.go
  7. +7
    -3
      options/locale/locale_en-US.ini
  8. +3
    -0
      options/locale/locale_zh-CN.ini
  9. +7
    -0
      routers/org/home.go
  10. +20
    -1
      routers/repo/cloudbrain.go
  11. +5
    -5
      routers/repo/modelarts.go
  12. +2
    -2
      templates/explore/repo_orgtop.tmpl
  13. +48
    -3
      templates/org/home.tmpl
  14. +4
    -24
      templates/org/home_courses.tmpl
  15. +11
    -2
      templates/repo/cloudbrain/benchmark/index.tmpl
  16. +9
    -2
      templates/repo/cloudbrain/benchmark/new.tmpl
  17. +35
    -1
      web_src/less/openi.less

+ 1
- 1
custom/public/css/git.openi.css View File

@@ -185,7 +185,7 @@
.homenews .ui.list>.item>.content{
color: #E8E8E8;
line-height: 1.8em;
width: calc(100% - 3.25em) !important;
width: calc(100% - 3.75em) !important;
}
.homenews .ui.list>.item{
padding: 0;


+ 8
- 5
models/cloudbrain.go View File

@@ -146,8 +146,10 @@ type Cloudbrain struct {
CkptName string //权重文件名称
ResultUrl string //推理结果的obs路径

User *User `xorm:"-"`
Repo *Repository `xorm:"-"`
User *User `xorm:"-"`
Repo *Repository `xorm:"-"`
BenchmarkTypeName string `xorm:"-"`
BenchmarkTypeRankLink string `xorm:"-"`
}

type CloudbrainInfo struct {
@@ -409,9 +411,10 @@ type BenchmarkTypes struct {
}

type BenchmarkType struct {
Id int `json:"id"`
First string `json:"first"` //一级算法类型名称
Second []*BenchmarkDataset `json:"second"`
Id int `json:"id"`
RankLink string `json:"rank_link"`
First string `json:"first"` //一级算法类型名称
Second []*BenchmarkDataset `json:"second"`
}

type BenchmarkDataset struct {


+ 2
- 2
models/org.go View File

@@ -180,8 +180,8 @@ func CreateOrganization(org, owner *User) (err error) {

// Add initial creator to organization and owner team.
if _, err = sess.Insert(&OrgUser{
UID: owner.ID,
OrgID: org.ID,
UID: owner.ID,
OrgID: org.ID,
IsPublic: setting.Service.DefaultOrgMemberVisible,
}); err != nil {
return fmt.Errorf("insert org-user relation: %v", err)


+ 13
- 0
models/topic.go View File

@@ -324,3 +324,16 @@ func SaveTopics(repoID int64, topicNames ...string) error {

return sess.Commit()
}

func GetOrgTopics(orgId int64) ([]Topic, error) {
result := make([]Topic, 0)
sql := "select distinct(t.*) from repository r " +
"inner join repo_topic rt on rt.repo_id = r.id " +
"inner join topic t on rt.topic_id = t.id " +
"where r.owner_id = ? order by repo_count desc limit 50"
if e := x.SQL(sql, orgId).Find(&result); e != nil {
return nil, e
}

return result, nil
}

+ 2
- 1
modules/modelarts/resty.go View File

@@ -35,7 +35,8 @@ const (
//error code
modelartsIllegalToken = "ModelArts.6401"
NotebookNotFound = "ModelArts.6404"
NotebookNoPermission = "ModelArts.6403"
NotebookNoPermission = "ModelArts.6407"
NotebookInvalid = "ModelArts.6400"
)

func getRestyClient() *resty.Client {


+ 6
- 0
modules/repository/fork.go View File

@@ -86,5 +86,11 @@ func ForkRepository(doer, owner *models.User, oldRepo *models.Repository, name,
if err := models.CopyLanguageStat(oldRepo, repo); err != nil {
log.Error("Copy language stat from oldRepo failed")
}
//inherit parent repo's topics
if len(oldRepo.Topics) > 0 {
if err := models.SaveTopics(repo.ID, oldRepo.Topics...); err != nil {
log.Error("SaveTopics failed when fork,e=%v", err)
}
}
return repo, models.CopyLFS(ctx, repo, oldRepo)
}

+ 7
- 3
options/locale/locale_en-US.ini View File

@@ -235,7 +235,7 @@ page_recommend_org_more=More Organizations
page_recommend_repo=Recommended Projects
page_recommend_repo_desc=Excellent AI projects recommendation. To show your project here,
page_recommend_repo_commit=Click here to submit.
page_recommend_repo_go=Click here to
page_recommend_repo_go=Click here to
page_recommend_repo_more=explore more projects.
page_dev_env=Collaborative Development Environment
page_dev_env_desc=Provide a collaborative development environment for AI development, which is the biggest highlight that distinguishes the OpenI AI Collaboration Platform from other traditional Git platforms.
@@ -1254,6 +1254,7 @@ issues.filter_sort.moststars = Most stars
issues.filter_sort.feweststars = Fewest stars
issues.filter_sort.mostforks = Most forks
issues.filter_sort.fewestforks = Fewest forks
issues.filter_sort.downloadtimes = Most downloaded
issues.action_open = Open
issues.action_close = Close
issues.action_label = Label
@@ -2088,14 +2089,17 @@ team_unit_disabled = (Disabled)
selected_couse=Selected Courses
release_course = Publish Course
all_keywords=All keywords
all_org_topics=All
max_selectedPro= Select up to 9 public projects
custom_select_courses = Customize selected courses
custom_select_courses = Customize selected courses
recommend_remain_pro = Remain
save_fail_tips = The upper limit is exceeded
select_again = Select more than 9, please select again!
custom_select_projects = Customize selected projects
custom_select_projects = Customize selected projects
customize = Customize
selected_project=Selected Projects
fold = Fold
unfold = Unfold

form.name_reserved = The organization name '%s' is reserved.
form.name_pattern_not_allowed = The pattern '%s' is not allowed in an organization name.


+ 3
- 0
options/locale/locale_zh-CN.ini View File

@@ -2096,6 +2096,7 @@ team_unit_disabled=(已禁用)
selected_couse=精选课程
release_course = 发布课程
all_keywords=全部关键字
all_org_topics=全部
max_selectedPro= 最多可选9个公开项目
custom_select_courses = 自定义精选课程
recommend_remain_pro = 还能推荐
@@ -2104,6 +2105,8 @@ select_again = 选择超过9个,请重新选择!
custom_select_projects = 自定义精选项目
customize = 自定义
selected_project=精选项目
fold = 折叠
unfold = 展开

form.name_reserved=组织名称 '%s' 是被保留的。
form.name_pattern_not_allowed=组织名称中不允许使用 "%s"。


+ 7
- 0
routers/org/home.go View File

@@ -94,6 +94,13 @@ func Home(ctx *context.Context) {
recommendCourseKeyWords, _ := repository.GetRecommendCourseKeyWords()
ctx.Data["CoursesKeywords"] = recommendCourseKeyWords

} else {
orgTopics, err := models.GetOrgTopics(org.ID)
if err != nil {
ctx.Error(500, "GetOrgTopics failed")
return
}
ctx.Data["OrgTopics"] = orgTopics
}

repos, count, err = models.SearchRepository(&models.SearchRepoOptions{


+ 20
- 1
routers/repo/cloudbrain.go View File

@@ -344,6 +344,8 @@ func CloudBrainBenchMarkShow(ctx *context.Context) {
if benchmarkTypes == nil {
if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil {
log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", setting.BenchmarkTypes, err, ctx.Data["MsgID"])
ctx.ServerError(err.Error(), err)
return
}
}
cloudBrainShow(ctx, tplCloudBrainBenchmarkShow)
@@ -409,7 +411,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) {
} else {
duration = int64(task.UpdatedUnix) - int64(task.CreatedUnix)
}
if benchmarkTypes != nil {
if task.BenchmarkTypeID > 0 {
for _, benchmarkType := range benchmarkTypes.BenchmarkType {
if task.BenchmarkTypeID == benchmarkType.Id {
ctx.Data["BenchmarkTypeName"] = benchmarkType.First
@@ -1058,6 +1060,13 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) {
return
}

if benchmarkTypes == nil {
if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil {
ctx.ServerError("Get BenchmarkTypes faild:", err)
return
}
}

for i, task := range ciTasks {
ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain)
ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource
@@ -1068,6 +1077,16 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) {
duration = int64(task.Cloudbrain.UpdatedUnix) - int64(task.Cloudbrain.CreatedUnix)
}
ciTasks[i].TrainJobDuration = util.AddZero(duration/3600000) + ":" + util.AddZero(duration%3600000/60000) + ":" + util.AddZero(duration%60000/1000)
ciTasks[i].BenchmarkTypeName = ""
if task.BenchmarkTypeID > 0 {
for _, benchmarkType := range benchmarkTypes.BenchmarkType {
if task.BenchmarkTypeID == benchmarkType.Id {
ciTasks[i].BenchmarkTypeRankLink = benchmarkType.RankLink
ciTasks[i].BenchmarkTypeName = benchmarkType.First
break
}
}
}
}

pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5)


+ 5
- 5
routers/repo/modelarts.go View File

@@ -320,7 +320,7 @@ func NotebookDebug2(ctx *context.Context) {
return
}

ctx.Redirect(result.Url)
ctx.Redirect(result.Url + "?token=" + result.Token)
}

func NotebookManage(ctx *context.Context) {
@@ -431,24 +431,24 @@ func NotebookDel(ctx *context.Context) {

if task.Status != string(models.ModelArtsCreateFailed) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsStopped) {
log.Error("the job(%s) has not been stopped", task.JobName)
ctx.ServerError("the job has not been stopped", errors.New("the job has not been stopped"))
ctx.RenderWithErr("the job has not been stopped", tplDebugJobIndex, nil)
return
}

_, err := modelarts.DelNotebook2(task.JobID)
if err != nil {
log.Error("DelNotebook2(%s) failed:%v", task.JobName, err.Error())
if strings.Contains(err.Error(), modelarts.NotebookNotFound) || strings.Contains(err.Error(), modelarts.NotebookNoPermission) {
if strings.Contains(err.Error(), modelarts.NotebookNotFound) || strings.Contains(err.Error(), modelarts.NotebookNoPermission) || strings.Contains(err.Error(), modelarts.NotebookInvalid){
log.Info("old notebook version")
} else {
ctx.ServerError("DelNotebook2 failed", err)
ctx.RenderWithErr(err.Error(), tplDebugJobIndex, nil)
return
}
}

err = models.DeleteJob(task)
if err != nil {
ctx.ServerError("DeleteJob failed", err)
ctx.RenderWithErr(err.Error(), tplDebugJobIndex, nil)
return
}



+ 2
- 2
templates/explore/repo_orgtop.tmpl View File

@@ -53,8 +53,8 @@
</div>
<div class="swiper-slide">
<div class="ui card">
<a class="image" href="https://git.openi.org.cn/JD_Group">
<img src="/img/org-jd@2x-80.jpg" alt="京东" title="京东">
<a class="image" href="https://git.openi.org.cn/JDOpenISCT">
<img src="/img/org-jd@2x-80.jpg" alt="京东智能供应链开源工具" title="京东智能供应链开源工具">
</a>
</div>
</div>


+ 48
- 3
templates/org/home.tmpl View File

@@ -22,22 +22,51 @@
<div class="ui container">
{{template "org/navber" .}}
{{template "org/select_pro" .}}
<div class="ui stackable grid">
<div class="ui sixteen wide computer column">
<div class="ui mobile reversed stackable grid">
<div class="ui sixteen wide tablet sixteen wide computer column margin-top20 pad-botom maxheight" id='key_tag'>
{{if .OrgTopics}}
<a class="{{if eq $.Keyword "" }} tag_bg {{end}} tag_key ui small tag_lable topic omit" href="{{$.Link}}?" >{{$.i18n.Tr "org.all_org_topics"}}</span></a>
{{end}}

{{range .OrgTopics}}
{{if ne .Name ""}}
<a class="{{if eq $.Keyword .Name }} tag_bg {{end}} tag_key ui small tag_lable topic omit" href="{{$.Link}}?q={{.Name}}" >
{{.Name}}
</a>
{{end}}
{{end}}
</div>
<div style="width: 100%;margin:5px 5px 10px;">
<a class="text-right" onclick="isUnfold()" id="icon_btn"><i class="ri-arrow-down-s-line" style="display:inline-block;vertical-align:top"></i>&nbsp{{.i18n.Tr "org.unfold"}}</a>
</div>
</div>
</div>
</div>
<div class="ui stackable grid">
<div class="ui sixteen wide computer column">
<div class="ui mobile reversed stackable grid">
<div class="ui ten wide tablet eleven wide computer column">
{{if .CanCreateOrgRepo}}
<!-- {{if .CanCreateOrgRepo}}
<div class="text right">
<a class="ui green button" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}">{{.i18n.Tr "new_repo"}}</a>
</div>
{{end}}
{{end}} -->
{{template "org/repo_list" .}}
{{template "base/paginate" .}}
</div>

<div class="ui sixteen wide mobile six wide tablet five wide computer column">
<h4 class="ui top attached header">
{{if .CanCreateOrgRepo}}
<div class="text right">
<a class="ui green button" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}">{{.i18n.Tr "new_repo"}}</a>
</div>
{{end}}
<h4 class="ui top attached header" style="margin-top: 10px;">
<strong>{{.i18n.Tr "org.people"}}</strong>
<div class="ui right">
<a class="text grey" href="{{.OrgLink}}/members">{{.MembersTotal}} {{svg "octicon-chevron-right" 16}}</a>
@@ -99,3 +128,19 @@
</div>
</div>
{{template "base/footer" .}}

<script>

function isUnfold(){
var isContain= document.querySelector("#key_tag").classList.contains("maxheight");
if(isContain){
document.querySelector("#key_tag").classList.remove("maxheight");
document.getElementById("icon_btn").innerHTML="<i class=\"ri-arrow-up-s-line\" style=\"display:inline-block;vertical-align:top\"></i> &nbsp {{.i18n.Tr "org.fold"}}"
}else{
document.querySelector("#key_tag").classList.add("maxheight");
document.getElementById("icon_btn").innerHTML="<i class=\"ri-arrow-down-s-line\" style=\"display:inline-block;vertical-align:top\"></i> &nbsp {{.i18n.Tr "org.unfold"}}"


}
}
</script>

+ 4
- 24
templates/org/home_courses.tmpl View File

@@ -32,27 +32,13 @@
.organization-info >.container {
padding-bottom:0px !important;
}
.tag_bg{
background-color: #0366D6 !important;
color:#FFFFFF !important;
}
.course{
padding:10px 0 15px !important;
}
.course_color{
color: #FA8C16;
}
.tag_lable{
border: 1px solid rgba(232, 232, 232, 100) ;
border-radius: 4px;
color: rgba(65, 80, 88, 100);
font-family: Microsoft Yahei;
font-size: 14px;
padding: 0.3em 0.5em;
height: 30px;
text-align: center;
margin: 0.2em;
}
.tag_lable_first{
border: 1px solid rgba(232, 232, 232, 100) ;
border-radius: 4px;
@@ -65,17 +51,11 @@
margin: 0.2em;
margin-left: none;
}
.tag_key{
max-width:100%;
margin: 3px 3px;
display:inline-flex;
}

.bpadding{
padding:10px 40px
}
.omit{
overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

.noborder{
border: none !important;
}
@@ -83,7 +63,7 @@
text-align: center;
margin-top: 5px;
margin-top: 10px;
}
}
</style>


+ 11
- 2
templates/repo/cloudbrain/benchmark/index.tmpl View File

@@ -39,7 +39,7 @@
</div>
</div>
<div class="column right aligned">
<a class="ui compact orange basic icon button" href="{{$.RepoLink}}/cloudbrain/123/rate?isObjectDetcionAll=true" style="box-shadow: none;" target="_blank"><i class="large ri-trophy-fill middle aligned icon"></i>基准测试排行榜</a>
<a class="ui compact orange basic icon button" href="https://openi.org.cn/projects/Benchmark/#algType" style="box-shadow: none;" target="_blank"><i class="large ri-trophy-fill middle aligned icon"></i>基准测试排行榜</a>
{{if .Permission.CanWrite $.UnitTypeCloudBrain}}
<a class="ui green button" href="{{.RepoLink}}/cloudbrain/benchmark/create">{{$.i18n.Tr "repo.modelarts.evaluate_job.new_job"}}</a>
{{else}}
@@ -76,9 +76,12 @@
<span>{{$.i18n.Tr "repo.modelarts.status"}}</span>
</div>
<div class="two wide column text center padding0">
<span>{{$.i18n.Tr "repo.modelarts.createtime"}}</span>
<span>{{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_type"}}</span>
</div>
<div class="two wide column text center padding0">
<span>{{$.i18n.Tr "repo.modelarts.createtime"}}</span>
</div>
<div class="one wide column text center padding0">
<span>{{$.i18n.Tr "repo.cloudbrain_status_runtime"}}</span>
</div>
<div class="two wide column text center padding0">
@@ -109,6 +112,11 @@
<span><i id="{{.Cloudbrain.ID}}-icon" style="vertical-align: middle;" class="{{.Status}}"></i><span id="{{.Cloudbrain.ID}}-text" style="margin-left: 0.4em;font-size: 12px;">{{.Status}}</span></span>
</span>
</div>
<div class="two wide column text center padding0">
<a style="font-size: 12px;" href="{{.BenchmarkTypeRankLink}}" target="_blank">
{{.BenchmarkTypeName}}
</a>
</div>
<!-- 任务创建时间 -->
<div class="two wide column text center padding0">
<span style="font-size: 12px;" class="">{{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}</span>
@@ -149,6 +157,7 @@
<a class="ui basic button {{if $.IsSigned}} blue{{else}} disabled{{end}}" href="{{$.RepoLink}}/cloudbrain/{{.Cloudbrain.ID}}/rate" target="_blank">
评分
</a>
<!-- 删除任务 -->
<form id="delForm-{{.Cloudbrain.ID}}" action="{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain/benchmark{{else}}{{$.RepoLink}}/modelarts/notebook{{end}}/{{.Cloudbrain.ID}}/del" method="post">
<input type="hidden" name="debugListType" value="all">


+ 9
- 2
templates/repo/cloudbrain/benchmark/new.tmpl View File

@@ -150,13 +150,13 @@
<div class="inline unite min_title field required">
<label style="font-weight: normal;">{{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_train"}}</label>
<input disabled="disabled" style="width: 33.5%;" name="train_file" id="train_file" value="train.py" tabindex="3" autofocus required maxlength="254" >
<a href="https://git.openi.org.cn/CV_benchmark/CV_reID_benchmark" target="_blank">查看样例</a>
<a id="train_href_id" href="https://git.openi.org.cn/CV_benchmark/CV_reID_benchmark" target="_blank">查看样例</a>
</div>

<div class="inline unite min_title field required">
<label style="font-weight: normal;">{{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_test"}}</label>
<input disabled="disabled" style="width: 33.5%;" name="test_file" id="test_file" value="test.py" tabindex="3" autofocus required maxlength="254" >
<a href="https://git.openi.org.cn/CV_benchmark/CV_reID_benchmark" target="_blank">查看样例</a>
<a id="test_href_id" href="https://git.openi.org.cn/CV_benchmark/CV_reID_benchmark" target="_blank">查看样例</a>
</div>

@@ -190,6 +190,13 @@

function setChildType(){
let type_id = $('#benchmark_types_id').val();
if(type_id == 3){
$('#train_href_id').attr('href','https://git.openi.org.cn/CV_benchmark/CV_MOT_benchmark');
$('#test_href_id').attr('href','https://git.openi.org.cn/CV_benchmark/CV_MOT_benchmark');
}else{
$('#train_href_id').attr('href','https://git.openi.org.cn/CV_benchmark/CV_reID_benchmark');
$('#test_href_id').attr('href','https://git.openi.org.cn/CV_benchmark/CV_reID_benchmark');
}
let child_selected_id = $('#benchmark_child_types_id_hidden').val();
$.get(`${repolink}/cloudbrain/benchmark/get_child_types?benchmark_type_id=${type_id}`, (data) => {
const n_length = data['child_types'].length


+ 35
- 1
web_src/less/openi.less View File

@@ -734,4 +734,38 @@ display: block;
}
.el-pagination.is-background .el-pager li:hover {
color: #5bb973 !important;
}
}

.tag_key{
max-width:100%;
margin: 3px 3px;
display:inline-flex;
}
.tag_lable{
border: 1px solid rgba(232, 232, 232, 100) ;
border-radius: 4px;
color: rgba(65, 80, 88, 100);
font-family: Microsoft Yahei;
font-size: 14px;
padding: 0.3em 0.5em;
height: 30px;
text-align: center;
margin: 0.2em;
}
.omit{
overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.tag_bg{
background-color: #0366D6 !important;
color:#FFFFFF !important;
}
.margin-top20{
margin-top: 20px;
}
.maxheight{
max-height: 88px;
overflow: hidden;
}
.pad-botom{
padding-bottom:0px !important;
}

Loading…
Cancel
Save