Browse Source

Merge branch 'V20220110' into fix-1156

pull/1258/head
zhoupzh 3 years ago
parent
commit
ba7d7e76d1
13 changed files with 78 additions and 17 deletions
  1. +1
    -1
      modules/modelarts/modelarts.go
  2. +10
    -0
      modules/util/util.go
  3. +2
    -0
      options/locale/locale_en-US.ini
  4. +2
    -0
      options/locale/locale_zh-CN.ini
  5. +2
    -10
      routers/api/v1/repo/modelarts.go
  6. +12
    -6
      routers/repo/cloudbrain.go
  7. +7
    -0
      templates/base/footer_content.tmpl
  8. +6
    -0
      templates/base/footer_content_fluid.tmpl
  9. +8
    -0
      templates/base/head_navbar.tmpl
  10. +8
    -0
      templates/base/head_navbar_fluid.tmpl
  11. +8
    -0
      templates/base/head_navbar_home.tmpl
  12. +8
    -0
      templates/base/head_navbar_pro.tmpl
  13. +4
    -0
      web_src/less/openi.less

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

@@ -357,7 +357,7 @@ func GenerateTrainJobVersion(ctx *context.Context, req *GenerateTrainJobReq, job
CommitID: req.CommitID,
IsLatestVersion: req.IsLatestVersion,
PreVersionName: req.PreVersionName,
ComputeResource: models.GPUResource,
ComputeResource: models.NPUResource,
EngineID: req.EngineID,
TrainUrl: req.TrainUrl,
BranchName: req.BranchName,


+ 10
- 0
modules/util/util.go View File

@@ -6,6 +6,7 @@ package util

import (
"bytes"
"strconv"
"strings"
)

@@ -100,3 +101,12 @@ func NormalizeEOL(input []byte) []byte {
}
return tmp[:pos]
}

func AddZero(t int64) (m string) {
if t < 10 {
m = "0" + strconv.FormatInt(t, 10)
return m
} else {
return strconv.FormatInt(t, 10)
}
}

+ 2
- 0
options/locale/locale_en-US.ini View File

@@ -2659,3 +2659,5 @@ foot.member_news = Member news
foot.industry_advisory = Industry Advisory
foot.help = help
foot.copyright= Copyright: New Generation Artificial Intelligence Open Source Open Platform (OpenI)
Platform_Tutorial=Platform Tutorial
foot.advice_feedback=advice feedback

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

@@ -2667,3 +2667,5 @@ foot.member_news=成员动态
foot.industry_advisory=行业资讯
foot.help=帮助
foot.copyright= 版权所有:新一代人工智能开源开放平台(OpenI)
Platform_Tutorial=新手指引
foot.advice_feedback = 意见反馈

+ 2
- 10
routers/api/v1/repo/modelarts.go View File

@@ -6,6 +6,7 @@
package repo

import (
"code.gitea.io/gitea/modules/util"
"net/http"
"strconv"
"strings"
@@ -106,7 +107,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) {
job.TrainJobDuration = result.TrainJobDuration

if result.Duration != 0 {
job.TrainJobDuration = addZero(result.Duration/3600000) + ":" + addZero(result.Duration%3600000/60000) + ":" + addZero(result.Duration%60000/1000)
job.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000)

} else {
job.TrainJobDuration = "00:00:00"
@@ -125,15 +126,6 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) {

}

func addZero(t int64) (m string) {
if t < 10 {
m = "0" + strconv.FormatInt(t, 10)
return m
} else {
return strconv.FormatInt(t, 10)
}
}

func TrainJobGetLog(ctx *context.APIContext) {
var (
err error


+ 12
- 6
routers/repo/cloudbrain.go View File

@@ -14,18 +14,17 @@ import (
"strings"
"time"

"code.gitea.io/gitea/modules/modelarts"

"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/storage"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/cloudbrain"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/modelarts"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/util"
)

const (
@@ -277,7 +276,7 @@ func CloudBrainRestart(ctx *context.Context) {
break
}

if !ctx.IsSigned || (ctx.User.ID != task.UserID && !ctx.IsUserSiteAdmin()){
if !ctx.IsSigned || (ctx.User.ID != task.UserID && !ctx.IsUserSiteAdmin()) {
log.Error("the user has no right ro restart the job", task.JobName, ctx.Data["MsgID"])
resultCode = "-1"
errorMsg = "you have no right to restart the job"
@@ -949,6 +948,13 @@ func SyncCloudbrainStatus() {
task.Duration = result.Duration
task.TrainJobDuration = result.TrainJobDuration

if result.Duration != 0 {
task.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000)

} else {
task.TrainJobDuration = "00:00:00"
}

err = models.UpdateJob(task)
if err != nil {
log.Error("UpdateJob(%s) failed:%v", task.JobName, err)


+ 7
- 0
templates/base/footer_content.tmpl View File

@@ -26,7 +26,14 @@
{{end}}
</div>
</div>
<a href="https://git.openi.org.cn/zeizei/OpenI_Learning" class="ui item" target="_blank">{{.i18n.Tr "custom.Platform_Tutorial"}}</a>
{{if .EnableSwagger}}<a href="/api/swagger" class="ui item">API</a>{{end}}
{{if .IsSigned}}
<a href="https://git.openi.org.cn/zeizei/OpenI_Learning/issues/new" class="ui item" target="_blank">{{.i18n.Tr "custom.foot.advice_feedback"}}</a>
{{else}}
<a href="{{AppSubUrl}}/user/login" class="ui item">{{.i18n.Tr "custom.foot.advice_feedback"}}</a>
{{end}}

{{template "custom/extra_links_footer" .}}
</div>
</div>


+ 6
- 0
templates/base/footer_content_fluid.tmpl View File

@@ -26,7 +26,13 @@
{{end}}
</div>
</div>
<a href="https://git.openi.org.cn/zeizei/OpenI_Learning" class="ui item" target="_blank">{{.i18n.Tr "custom.Platform_Tutorial"}}</a>
{{if .EnableSwagger}}<a href="/api/swagger" class="ui item">API</a>{{end}}
{{if .IsSigned}}
<a href="https://git.openi.org.cn/zeizei/OpenI_Learning/issues/new" class="ui item" target="_blank">{{.i18n.Tr "custom.foot.advice_feedback"}}</a>
{{else}}
<a href="{{AppSubUrl}}/user/login" class="ui item">{{.i18n.Tr "custom.foot.advice_feedback"}}</a>
{{end}}
{{template "custom/extra_links_footer" .}}
</div>
</div>


+ 8
- 0
templates/base/head_navbar.tmpl View File

@@ -168,6 +168,14 @@
{{svg "octicon-question" 16}}
{{.i18n.Tr "help"}}<!-- Help -->
</a-->
<a class="item" href="https://git.openi.org.cn/zeizei/OpenI_Learning" target="_blank">
<i class="tutorial_icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
<path fill="none" d="M0 0h24v24H0z"/><path d="M2 3.993A1 1 0 0 1 2.992 3h18.016c.548 0 .992.445.992.993v16.014a1 1 0 0 1-.992.993H2.992A.993.993 0 0 1 2 20.007V3.993zM12 5v14h8V5h-8zm1 2h6v2h-6V7zm0 3h6v2h-6v-2z"/>
</svg>
</i>
{{.i18n.Tr "custom.Platform_Tutorial"}}
</a>
{{if .IsAdmin}}
<div class="divider"></div>



+ 8
- 0
templates/base/head_navbar_fluid.tmpl View File

@@ -166,6 +166,14 @@
{{svg "octicon-question" 16}}
{{.i18n.Tr "help"}}<!-- Help -->
</a-->
<a class="item" href="https://git.openi.org.cn/zeizei/OpenI_Learning" target="_blank">
<i class="tutorial_icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
<path fill="none" d="M0 0h24v24H0z"/><path d="M2 3.993A1 1 0 0 1 2.992 3h18.016c.548 0 .992.445.992.993v16.014a1 1 0 0 1-.992.993H2.992A.993.993 0 0 1 2 20.007V3.993zM12 5v14h8V5h-8zm1 2h6v2h-6V7zm0 3h6v2h-6v-2z"/>
</svg>
</i>
{{.i18n.Tr "custom.Platform_Tutorial"}}
</a>
{{if .IsAdmin}}
<div class="divider"></div>



+ 8
- 0
templates/base/head_navbar_home.tmpl View File

@@ -148,6 +148,14 @@
{{svg "octicon-question" 16}}
{{.i18n.Tr "help"}}<!-- Help -->
</a-->
<a class="item" href="https://git.openi.org.cn/zeizei/OpenI_Learning" target="_blank">
<i class="tutorial_icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
<path fill="none" d="M0 0h24v24H0z"/><path d="M2 3.993A1 1 0 0 1 2.992 3h18.016c.548 0 .992.445.992.993v16.014a1 1 0 0 1-.992.993H2.992A.993.993 0 0 1 2 20.007V3.993zM12 5v14h8V5h-8zm1 2h6v2h-6V7zm0 3h6v2h-6v-2z"/>
</svg>
</i>
{{.i18n.Tr "custom.Platform_Tutorial"}}
</a>
{{if .IsAdmin}}
<div class="divider"></div>



+ 8
- 0
templates/base/head_navbar_pro.tmpl View File

@@ -169,6 +169,14 @@
{{svg "octicon-question" 16}}
{{.i18n.Tr "help"}}<!-- Help -->
</a-->
<a class="item" href="https://git.openi.org.cn/zeizei/OpenI_Learning" target="_blank">
<i class="tutorial_icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
<path fill="none" d="M0 0h24v24H0z"/><path d="M2 3.993A1 1 0 0 1 2.992 3h18.016c.548 0 .992.445.992.993v16.014a1 1 0 0 1-.992.993H2.992A.993.993 0 0 1 2 20.007V3.993zM12 5v14h8V5h-8zm1 2h6v2h-6V7zm0 3h6v2h-6v-2z"/>
</svg>
</i>
{{.i18n.Tr "custom.Platform_Tutorial"}}
</a>
{{if .IsAdmin}}
<div class="divider"></div>



+ 4
- 0
web_src/less/openi.less View File

@@ -585,3 +585,7 @@ display: block;
margin-top: 0.7rem;
color: #888888;
}
.tutorial_icon{
vertical-align: middle;
margin-right: 0.75em;
}

Loading…
Cancel
Save