Browse Source

Merge branch 'V20220616' into download-npu-log

pull/2266/head
zhoupzh 3 years ago
parent
commit
44e8dab53d
25 changed files with 547 additions and 24 deletions
  1. +11
    -0
      models/cloudbrain.go
  2. +1
    -0
      modules/auth/repo_form.go
  3. +41
    -0
      modules/modelarts/resty.go
  4. +3
    -1
      options/locale/locale_en-US.ini
  5. +3
    -1
      options/locale/locale_zh-CN.ini
  6. +1
    -0
      public/self/css/notebook/katex.min.css
  7. +86
    -0
      public/self/css/notebook/notebook.css
  8. +142
    -0
      public/self/css/notebook/prism.css
  9. +6
    -0
      public/self/js/notebook/ansi_up.min.js
  10. +7
    -0
      public/self/js/notebook/es5-shim.min.js
  11. +1
    -0
      public/self/js/notebook/katex-auto-render.min.js
  12. +1
    -0
      public/self/js/notebook/katex.min.js
  13. +1
    -0
      public/self/js/notebook/marked.min.js
  14. +1
    -0
      public/self/js/notebook/notebook.min.js
  15. +7
    -0
      public/self/js/notebook/prism.min.js
  16. +3
    -0
      public/self/js/notebook/purify.min.js
  17. +1
    -0
      routers/api/v1/api.go
  18. +43
    -0
      routers/api/v1/repo/modelarts.go
  19. +6
    -2
      routers/repo/repo.go
  20. +4
    -0
      routers/repo/view.go
  21. +38
    -19
      templates/repo/create.tmpl
  22. +12
    -0
      templates/repo/header.tmpl
  23. +8
    -0
      templates/repo/modelarts/trainjob/show.tmpl
  24. +14
    -0
      templates/repo/view_file.tmpl
  25. +106
    -1
      web_src/js/index.js

+ 11
- 0
models/cloudbrain.go View File

@@ -1150,6 +1150,17 @@ type LogFile struct {
Name string
}

type GetTrainJobMetricStatisticResult struct {
TrainJobResult
Interval int `json:"interval"` //查询的时间间隔,单位为分钟
MetricsInfo []Metrics `json:"metrics"` //监控详情
}

type Metrics struct {
Metric string `json:"metric"` //监控指标项
Value []string `json:"value"` //获取的监控值的序列,元素为String类型
}

func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) {
sess := x.NewSession()
defer sess.Close()


+ 1
- 0
modules/auth/repo_form.go View File

@@ -46,6 +46,7 @@ type CreateRepoForm struct {
Webhooks bool
Avatar bool
Labels bool
AutoAgree bool
}

// Validate validates the fields


+ 41
- 0
modules/modelarts/resty.go View File

@@ -1119,3 +1119,44 @@ sendjob:

return &result, nil
}

func GetTrainJobMetricStatistic(jobID, versionID, podName string) (*models.GetTrainJobMetricStatisticResult, error) {
checkSetting()
client := getRestyClient()
var result models.GetTrainJobMetricStatisticResult

retry := 0

sendjob:
res, err := client.R().
SetAuthToken(TOKEN).
SetResult(&result).
Get(HOST + "/v1/" + setting.ProjectID + urlTrainJob + "/" + jobID + "/versions/" + versionID + "/pod/" + podName + "/metric-statistic")

if err != nil {
return nil, fmt.Errorf("resty GetTrainJobMetricStatistic: %v", err)
}

if res.StatusCode() == http.StatusUnauthorized && retry < 1 {
retry++
_ = getToken()
goto sendjob
}

if res.StatusCode() != http.StatusOK {
var temp models.ErrorResult
if err = json.Unmarshal([]byte(res.String()), &temp); err != nil {
log.Error("json.Unmarshal failed(%s): %v", res.String(), err.Error())
return &result, fmt.Errorf("json.Unmarshal failed(%s): %v", res.String(), err.Error())
}
log.Error("GetTrainJobMetricStatistic failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg)
return &result, fmt.Errorf("GetTrainJobMetricStatistic failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg)
}

if !result.IsSuccess {
log.Error("GetTrainJobMetricStatistic(%s) failed", jobID)
return &result, fmt.Errorf("获取任务资源占用情况失败:%s", result.ErrorMsg)
}

return &result, nil
}

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

@@ -1184,6 +1184,7 @@ template.topics = Topics
template.avatar = Avatar
template.issue_labels = Issue Labels
template.one_item = Must select at least one template item
template.one_promise = Must agree to use the agreement!
template.invalid = Must select a template repository
template.repo_adress=Adress
template.repo_path=path
@@ -2258,7 +2259,8 @@ topic.done = Done
topic.count_prompt = You can not select more than 25 topics
topic.format_prompt = Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.
imagetopic.format_prompt = Topics can be up to 35 characters long.

use_repo_agreement=I promise that the content of this warehouse does not violate any national laws and regulations. During the use of the warehouse, I will abide by the OpenI community management regulations and platform usage rules, and will not conduct malicious attacks, mining, or any other illegal or disruptive platform order. Information release and related behaviors. For more information please refer to
openi_use_agreement=OpenI Qizhi Community Platform Use Agreement.
[org]
org_name_holder = Organization Name
org_full_name_holder = Organization Full Name


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

@@ -1194,6 +1194,7 @@ template.topics=主题
template.avatar=头像
template.issue_labels=任务标签
template.one_item=必须至少选择一个模板项
template.one_promise=创建项目需承诺使用协议!
template.invalid=必须选择一个模板项目
template.repo_adress=项目地址
template.repo_path=项目地址
@@ -2268,7 +2269,8 @@ topic.done=保存
topic.count_prompt=您最多选择25个标签
topic.format_prompt=标签必须以中文、字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
imagetopic.format_prompt=标签长度不得超过35个字符

use_repo_agreement=我承诺此仓内容不违反任何国家法律法规,仓库使用过程中遵守OpenI启智社区管理规定和平台使用规则,不进行恶意攻击、挖矿等任何违法或扰乱平台秩序的信息发布和相关行为。更多信息请参考
openi_use_agreement=OpenI启智社区平台使用协议
[org]
org_name_holder=组织名称
org_full_name_holder=组织全名


+ 1
- 0
public/self/css/notebook/katex.min.css
File diff suppressed because it is too large
View File


+ 86
- 0
public/self/css/notebook/notebook.css View File

@@ -0,0 +1,86 @@
.nb-notebook {
line-height: 1.5;
margin-left: 7em;
}

.nb-stdout, .nb-stderr {
white-space: pre-wrap;
margin: 1em 0;
padding: 0.1em 0.5em;
}

.nb-stderr {
background-color: #FAA;
}

.nb-cell + .nb-cell {
margin-top: 0.5em;
}

.nb-output table {
border: 1px solid #000;
border-collapse: collapse;
}

.nb-output th {
font-weight: bold;
}

.nb-output th, .nb-output td {
border: 1px solid #000;
padding: 0.25em;
text-align: left;
vertical-align: middle;
border-collapse: collapse;
}

.nb-notebook blockquote {
border-left: 5px solid #CCC;
margin-left: 0;
padding-left: 1em;
}

.nb-cell {
position: relative;
}

.nb-raw-cell {
white-space: pre-wrap;
background-color: #f5f2f0;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
padding: 1em;
margin: .5em 0;
}

.nb-output {
min-height: 1em;
width: 100%;
overflow-x: scroll;
border-right: 1px dotted #CCC;
}

.nb-output img {
max-width: 100%;
}

.nb-output:before, .nb-input:before {
position: absolute;
font-family: monospace;
color: #999;
left: -7em;
width: 7em;
text-align: right;
}

.nb-input:before {
content: "In [" attr(data-prompt-number) "]:";
}
.nb-output:before {
content: "Out [" attr(data-prompt-number) "]:";
}

// Fix pandas dataframe formatting
div[style="max-height:1000px;max-width:1500px;overflow:auto;"] {
max-height: none !important;
}


+ 142
- 0
public/self/css/notebook/prism.css View File

@@ -0,0 +1,142 @@
/* PrismJS 1.21.0
https://prismjs.com/download.html#themes=prism&languages=markup+clike+javascript+julia+python+r */
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/

code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;

-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;

-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}

pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}

pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}

@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}

/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}

:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}

.token.punctuation {
color: #999;
}

.token.namespace {
opacity: .7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #9a6e3a;
/* This background color was intended by the author of this theme. */
background: hsla(0, 0%, 100%, .5);
}

.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}

.token.function,
.token.class-name {
color: #DD4A68;
}

.token.regex,
.token.important,
.token.variable {
color: #e90;
}

.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}

.token.entity {
cursor: help;
}

+ 6
- 0
public/self/js/notebook/ansi_up.min.js View File

@@ -0,0 +1,6 @@
// ansi_up.js
// version : 1.1.0
// author : Dru Nelson
// license : MIT
// http://github.com/drudru/ansi_up
(function(a,b){function g(){this.fg=this.bg=null,this.bright=0}var c,d="1.1.0",e=typeof module!="undefined",f=[[{color:"0, 0, 0","class":"ansi-black"},{color:"187, 0, 0","class":"ansi-red"},{color:"0, 187, 0","class":"ansi-green"},{color:"187, 187, 0","class":"ansi-yellow"},{color:"0, 0, 187","class":"ansi-blue"},{color:"187, 0, 187","class":"ansi-magenta"},{color:"0, 187, 187","class":"ansi-cyan"},{color:"255,255,255","class":"ansi-white"}],[{color:"85, 85, 85","class":"ansi-bright-black"},{color:"255, 85, 85","class":"ansi-bright-red"},{color:"0, 255, 0","class":"ansi-bright-green"},{color:"255, 255, 85","class":"ansi-bright-yellow"},{color:"85, 85, 255","class":"ansi-bright-blue"},{color:"255, 85, 255","class":"ansi-bright-magenta"},{color:"85, 255, 255","class":"ansi-bright-cyan"},{color:"255, 255, 255","class":"ansi-bright-white"}]];g.prototype.escape_for_html=function(a){return a.replace(/[&<>]/gm,function(a){if(a=="&")return"&amp;";if(a=="<")return"&lt;";if(a==">")return"&gt;"})},g.prototype.linkify=function(a){return a.replace(/(https?:\/\/[^\s]+)/gm,function(a){return'<a href="'+a+'">'+a+"</a>"})},g.prototype.ansi_to_html=function(a,b){var c=a.split(/\033\[/),d=c.shift(),e=this,f=c.map(function(a){return e.process_chunk(a,b)});f.unshift(d);var g=f.reduce(function(a,b){return Array.isArray(b)?a.concat(b):(a.push(b),a)},[]),h=g.join("");return h},g.prototype.process_chunk=function(a,b){b=typeof b=="undefined"?{}:b;var c=typeof b.use_classes!="undefined"&&b.use_classes,d=c?"class":"color",e=a.match(/([\d;]*)m([^]*)/m);if(!e)return a;var g=e[2],h=e[1].split(";"),i=this;h.map(function(a){var b=parseInt(a);isNaN(b)||b===0?(i.fg=i.bg=null,i.bright=0):b===1?i.bright=1:b>=30&&b<38?i.fg=f[i.bright][b%10][d]:b>=40&&b<48&&(i.bg=f[0][b%10][d])});if(i.fg===null&&i.bg===null)return g;var j=classes=[];return i.fg&&(c?classes.push(i.fg+"-fg"):j.push("color:rgb("+i.fg+")")),i.bg&&(c?classes.push(i.bg+"-bg"):j.push("background-color:rgb("+i.bg+")")),c?['<span class="'+classes.join(" ")+'">',g,"</span>"]:['<span style="'+j.join(";")+'">',g,"</span>"]},c={escape_for_html:function(a){var b=new g;return b.escape_for_html(a)},linkify:function(a){var b=new g;return b.linkify(a)},ansi_to_html:function(a,b){var c=new g;return c.ansi_to_html(a,b)},ansi_to_html_obj:function(){return new g}},e&&(module.exports=c),typeof window!="undefined"&&typeof ender=="undefined"&&(window.ansi_up=c),typeof define=="function"&&define.amd&&define("ansi_up",[],function(){return c})})(Date);

+ 7
- 0
public/self/js/notebook/es5-shim.min.js
File diff suppressed because it is too large
View File


+ 1
- 0
public/self/js/notebook/katex-auto-render.min.js View File

@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("katex")):"function"==typeof define&&define.amd?define(["katex"],t):"object"==typeof exports?exports.renderMathInElement=t(require("katex")):e.renderMathInElement=t(e.katex)}("undefined"!=typeof self?self:this,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),a=function(e,t,r){for(var n=r,o=0,a=e.length;n<t.length;){var i=t[n];if(o<=0&&t.slice(n,n+a)===e)return n;"\\"===i?n++:"{"===i?o++:"}"===i&&o--,n++}return-1},i=function(e,t,r,n){for(var o=[],i=0;i<e.length;i++)if("text"===e[i].type){var l=e[i].data,d=!0,s=0,f=void 0;for(-1!==(f=l.indexOf(t))&&(s=f,o.push({type:"text",data:l.slice(0,s)}),d=!1);;){if(d){if(-1===(f=l.indexOf(t,s)))break;o.push({type:"text",data:l.slice(s,f)}),s=f}else{if(-1===(f=a(r,l,s+t.length)))break;o.push({type:"math",data:l.slice(s+t.length,f),rawData:l.slice(s,f+r.length),display:n}),s=f+r.length}d=!d}o.push({type:"text",data:l.slice(s)})}else o.push(e[i]);return o},l=function(e,t){var r=function(e,t){for(var r=[{type:"text",data:e}],n=0;n<t.length;n++){var o=t[n];r=i(r,o.left,o.right,o.display||!1)}return r}(e,t.delimiters);if(1===r.length&&"text"===r[0].type)return null;for(var n=document.createDocumentFragment(),a=0;a<r.length;a++)if("text"===r[a].type)n.appendChild(document.createTextNode(r[a].data));else{var l=document.createElement("span"),d=r[a].data;t.displayMode=r[a].display;try{t.preProcess&&(d=t.preProcess(d)),o.a.render(d,l,t)}catch(e){if(!(e instanceof o.a.ParseError))throw e;t.errorCallback("KaTeX auto-render: Failed to parse `"+r[a].data+"` with ",e),n.appendChild(document.createTextNode(r[a].rawData));continue}n.appendChild(l)}return n};t.default=function(e,t){if(!e)throw new Error("No element provided to render");var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);r.delimiters=r.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\[",right:"\\]",display:!0}],r.ignoredTags=r.ignoredTags||["script","noscript","style","textarea","pre","code","option"],r.ignoredClasses=r.ignoredClasses||[],r.errorCallback=r.errorCallback||console.error,r.macros=r.macros||{},function e(t,r){for(var n=0;n<t.childNodes.length;n++){var o=t.childNodes[n];if(3===o.nodeType){var a=l(o.textContent,r);a&&(n+=a.childNodes.length-1,t.replaceChild(a,o))}else 1===o.nodeType&&function(){var t=" "+o.className+" ";-1===r.ignoredTags.indexOf(o.nodeName.toLowerCase())&&r.ignoredClasses.every(function(e){return-1===t.indexOf(" "+e+" ")})&&e(o,r)}()}}(e,r)}}]).default});

+ 1
- 0
public/self/js/notebook/katex.min.js
File diff suppressed because it is too large
View File


+ 1
- 0
public/self/js/notebook/marked.min.js
File diff suppressed because it is too large
View File


+ 1
- 0
public/self/js/notebook/notebook.min.js
File diff suppressed because it is too large
View File


+ 7
- 0
public/self/js/notebook/prism.min.js
File diff suppressed because it is too large
View File


+ 3
- 0
public/self/js/notebook/purify.min.js
File diff suppressed because it is too large
View File


+ 1
- 0
routers/api/v1/api.go View File

@@ -922,6 +922,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/del_version", repo.DelTrainJobVersion)
m.Post("/stop_version", repo.StopTrainJobVersion)
m.Get("/model_list", repo.ModelList)
m.Get("/metric_statistics", repo.TrainJobGetMetricStatistic)
})
})
m.Group("/inference-job", func() {


+ 43
- 0
routers/api/v1/repo/modelarts.go View File

@@ -462,3 +462,46 @@ func ResultList(ctx *context.APIContext) {
"PageIsCloudBrain": true,
})
}

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

var jobID = ctx.Params(":jobid")
var versionName = ctx.Query("version_name")

result, err := trainJobGetMetricStatistic(jobID, versionName)
if err != nil {
log.Error("trainJobGetMetricStatistic(%s) failed:%v", jobID, err.Error())
return
}

ctx.JSON(http.StatusOK, map[string]interface{}{
"JobID": jobID,
"Interval": result.Interval,
"MetricsInfo": result.MetricsInfo,
})
}

func trainJobGetMetricStatistic(jobID string, versionName string) (*models.GetTrainJobMetricStatisticResult, error) {
task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName)
if err != nil {
log.Error("GetCloudbrainByJobIDAndVersionName(%s) failed:%v", jobID, err.Error())
return nil, err
}

resultLogFile, err := modelarts.GetTrainJobLogFileNames(jobID, strconv.FormatInt(task.VersionID, 10))
if err != nil {
log.Error("GetTrainJobLogFileNames(%s) failed:%v", jobID, err.Error())
return nil, err
}

result, err := modelarts.GetTrainJobMetricStatistic(jobID, strconv.FormatInt(task.VersionID, 10), resultLogFile.LogFileList[0])
if err != nil {
log.Error("GetTrainJobMetricStatistic(%s) failed:%v", jobID, err.Error())
return nil, err
}

return result, err
}

+ 6
- 2
routers/repo/repo.go View File

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

import (
"code.gitea.io/gitea/modules/validation"
"fmt"
"net/url"
"os"
@@ -15,6 +14,8 @@ import (
"strings"
"unicode/utf8"

"code.gitea.io/gitea/modules/validation"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth"
"code.gitea.io/gitea/modules/base"
@@ -193,7 +194,10 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) {
return
}
ctx.Data["ContextUser"] = ctxUser

if !form.AutoAgree {
ctx.RenderWithErr(ctx.Tr("repo.template.one_promise"), tplCreate, form)
return
}
if ctx.HasError() {
ctx.HTML(200, tplCreate)
return


+ 4
- 0
routers/repo/view.go View File

@@ -471,6 +471,8 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st

readmeExist := markup.IsReadmeFile(blob.Name())
ctx.Data["ReadmeExist"] = readmeExist
isNoteBook := strings.HasSuffix(blob.Name(), ".ipynb")
ctx.Data["IsNoteBook"] = isNoteBook
if markupType := markup.Type(blob.Name()); markupType != "" {
ctx.Data["IsMarkup"] = true
ctx.Data["MarkupType"] = markupType
@@ -480,6 +482,8 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
ctx.Data["FileContent"] = strings.Replace(
gotemplate.HTMLEscapeString(string(buf)), "\n", `<br>`, -1,
)
} else if isNoteBook {
ctx.Data["FileContent"] = string(buf)
} else {
// Building code view blocks with line number on server side.
var fileContent string


+ 38
- 19
templates/repo/create.tmpl View File

@@ -15,11 +15,11 @@
<label>{{.i18n.Tr "repo.visibility"}}</label>
<div class="ui checkbox">
{{if .IsForcedPrivate}}
<input name="private" type="checkbox" checked readonly>
<label>{{.i18n.Tr "repo.visibility_helper_forced" | Safe}}</label>
<input name="private" type="checkbox" checked readonly>
<label>{{.i18n.Tr "repo.visibility_helper_forced" | Safe}}</label>
{{else}}
<input name="private" type="checkbox" {{if .private}}checked{{end}}>
<label>{{.i18n.Tr "repo.visibility_helper" | Safe}}</label>
<input name="private" type="checkbox" {{if .private}}checked{{end}}>
<label>{{.i18n.Tr "repo.visibility_helper" | Safe}}</label>
{{end}}
</div>
<span class="help">{{.i18n.Tr "repo.visibility_description"}}</span>
@@ -42,33 +42,41 @@
<div class="inline field">
<label>{{.i18n.Tr "repo.template.items"}}</label>
<div class="ui checkbox">
<input class="hidden" name="git_content" type="checkbox" tabindex="0" {{if .git_content}}checked{{end}}>
<input class="hidden" name="git_content" type="checkbox" tabindex="0"
{{if .git_content}}checked{{end}}>
<label>{{.i18n.Tr "repo.template.git_content"}}</label>
</div>
<div class="ui checkbox" {{if not .SignedUser.CanEditGitHook}}data-tooltip="{{.i18n.Tr "repo.template.git_hooks_tooltip"}}"{{end}}>
<input class="hidden" name="git_hooks" type="checkbox" tabindex="0" {{if .git_hooks}}checked{{end}}>
<div class="ui checkbox"
{{if not .SignedUser.CanEditGitHook}}data-tooltip="{{.i18n.Tr "repo.template.git_hooks_tooltip"}}"
{{end}}>
<input class="hidden" name="git_hooks" type="checkbox" tabindex="0"
{{if .git_hooks}}checked{{end}}>
<label>{{.i18n.Tr "repo.template.git_hooks"}}</label>
</div>
</div>
<div class="inline field">
<label></label>
<div class="ui checkbox">
<input class="hidden" name="webhooks" type="checkbox" tabindex="0" {{if .webhooks}}checked{{end}}>
<input class="hidden" name="webhooks" type="checkbox" tabindex="0"
{{if .webhooks}}checked{{end}}>
<label>{{.i18n.Tr "repo.template.webhooks"}}</label>
</div>
<div class="ui checkbox">
<input class="hidden" name="topics" type="checkbox" tabindex="0" {{if .topics}}checked{{end}}>
<input class="hidden" name="topics" type="checkbox" tabindex="0"
{{if .topics}}checked{{end}}>
<label>{{.i18n.Tr "repo.template.topics"}}</label>
</div>
</div>
<div class="inline field">
<label></label>
<div class="ui checkbox">
<input class="hidden" name="avatar" type="checkbox" tabindex="0" {{if .avatar}}checked{{end}}>
<input class="hidden" name="avatar" type="checkbox" tabindex="0"
{{if .avatar}}checked{{end}}>
<label>{{.i18n.Tr "repo.template.avatar"}}</label>
</div>
<div class="ui checkbox">
<input class="hidden" name="labels" type="checkbox" tabindex="0" {{if .labels}}checked{{end}}>
<input class="hidden" name="labels" type="checkbox" tabindex="0"
{{if .labels}}checked{{end}}>
<label>{{.i18n.Tr "repo.template.issue_labels"}}</label>
</div>
</div>
@@ -83,7 +91,8 @@
<div class="menu">
<div class="item" data-value="">{{.i18n.Tr "repo.issue_labels_helper"}}</div>
{{range $template, $labels := .LabelTemplates}}
<div class="item" data-value="{{$template}}">{{$template}}<br/><i>({{$labels}})</i></div>
<div class="item" data-value="{{$template}}">{{$template}}<br /><i>({{$labels}})</i>
</div>
{{end}}
</div>
</div>
@@ -98,7 +107,7 @@
<div class="default text">{{.i18n.Tr "repo.repo_gitignore_helper"}}</div>
<div class="menu">
{{range .Gitignores}}
<div class="item" data-value="{{.}}">{{.}}</div>
<div class="item" data-value="{{.}}">{{.}}</div>
{{end}}
</div>
</div>
@@ -111,7 +120,7 @@
<div class="menu">
<div class="item" data-value="">{{.i18n.Tr "repo.license_helper"}}</div>
{{range .Licenses}}
<div class="item" data-value="{{.}}">{{.}}</div>
<div class="item" data-value="{{.}}">{{.}}</div>
{{end}}
</div>
</div>
@@ -124,24 +133,34 @@
<div class="default text">{{.i18n.Tr "repo.readme_helper"}}</div>
<div class="menu">
{{range .Readmes}}
<div class="item" data-value="{{.}}">{{.}}</div>
<div class="item" data-value="{{.}}">{{.}}</div>
{{end}}
</div>
</div>
</div>
<div class="inline field">
<div class="ui checkbox" id="auto-init">
<input class="hidden" name="auto_init" type="checkbox" tabindex="0" {{if .auto_init}}checked{{end}}>
<input class="hidden" name="auto_init" type="checkbox" tabindex="0"
{{if .auto_init}}checked{{end}}>
<label>{{.i18n.Tr "repo.auto_init"}}</label>
</div>
</div>
<div class="inline field">
<label for="default_branch">{{.i18n.Tr "repo.default_branch"}}</label>
<input id="default_branch" name="default_branch" value="{{.default_branch}}" placeholder="master">
<input id="default_branch" name="default_branch" value="{{.default_branch}}"
placeholder="master">
</div>
<div class="inline field">
<div class="ui checkbox" id="auto-init">
<input class="hidden" name="auto_agree" type="checkbox" checked="checked">
<label
style="width: 76%;text-align: justify;line-height: 1.5;">{{.i18n.Tr "repo.use_repo_agreement"}}
<a href="/home/term/">{{.i18n.Tr "repo.openi_use_agreement"}}</a></label>
</div>
</div>
</div>

<br/>
<br />
<div class="inline field">
<label></label>
<button class="ui green button" id="submit_reponame">
@@ -154,4 +173,4 @@
</div>
</div>
</div>
{{template "base/footer" .}}
{{template "base/footer" .}}

+ 12
- 0
templates/repo/header.tmpl View File

@@ -182,3 +182,15 @@


<script src="{{StaticUrlPrefix}}/js/jquery.js?v={{MD5 AppVer}}"></script>
<script src="{{StaticUrlPrefix}}/self/js/notebook/es5-shim.min.js"></script>
<script src="{{StaticUrlPrefix}}/self/js/notebook/marked.min.js"></script>
<script src="{{StaticUrlPrefix}}/self/js/notebook/purify.min.js"></script>
<script src="{{StaticUrlPrefix}}/self/js/notebook/ansi_up.min.js"></script>
<script src="{{StaticUrlPrefix}}/self/js/notebook/prism.min.js"></script>
<script src="{{StaticUrlPrefix}}/self/js/notebook/katex.min.js"></script>
<script src="{{StaticUrlPrefix}}/self/js/notebook/katex-auto-render.min.js"></script>
<script src="{{StaticUrlPrefix}}/self/js/notebook/notebook.min.js"></script>
<script src="{{StaticUrlPrefix}}/self/js/notebook/notebook.min.js"></script>
<link rel="stylesheet" href="{{StaticUrlPrefix}}/self/css/notebook/katex.min.css" />
<link rel="stylesheet" href="{{StaticUrlPrefix}}/self/css/notebook/prism.css" />
<link rel="stylesheet" href="{{StaticUrlPrefix}}/self/css/notebook/notebook.css" />

+ 8
- 0
templates/repo/modelarts/trainjob/show.tmpl View File

@@ -312,6 +312,7 @@
data-tab="first{{$k}}">{{$.i18n.Tr "repo.modelarts.train_job.config"}}</a>
<a class="item log_bottom" data-tab="second{{$k}}"
data-version="{{.VersionName}}">{{$.i18n.Tr "repo.modelarts.log"}}</a>
<a class="item metric_chart" data-tab="four{{$k}}" data-version="{{.VersionName}}">资源占用情况</a>
<a class="item" data-tab="third{{$k}}"
onclick="loadModelFile({{.VersionName}},'','','init')">{{$.i18n.Tr "repo.model_download"}}</a>
</div>
@@ -518,6 +519,13 @@
</div>

</div>
<div class="ui tab" data-tab="four{{$k}}" style="position: relative;">
<i class="ri-refresh-line metric_chart"
style="position: absolute;right: 25%;color:#3291f8;z-index:99;cursor: pointer;"
data-version="{{.VersionName}}"></i>
<div id="metric-{{.VersionName}}" style="height: 260px;width: 870px;">
</div>
</div>
<div class="ui tab" data-tab="third{{$k}}">
<input type="hidden" name="model{{.VersionName}}" value="-1">
<input type="hidden" name="modelback{{.VersionName}}" value="-1">


+ 14
- 0
templates/repo/view_file.tmpl View File

@@ -108,6 +108,8 @@
<tr>
{{if .IsFileTooLarge}}
<td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td>
{{else if .IsNoteBook}}
<td id="notebook"></td>
{{else}}
<td class="lines-num">{{.LineNums}}</td>
<td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td>
@@ -128,4 +130,16 @@ function submitDeleteForm() {
$("#delete-file-form").submit()
}
}
function showNoteBook(){
var isNoteBook = {{.IsNoteBook}}
if (isNoteBook) {
var jsonStr = "{{.FileContent}}"
var notebook = nb.parse(JSON.parse(jsonStr));
var rendered = notebook.render();
$("#notebook").append(rendered);
Prism.highlightAll();
}
}
showNoteBook()

</script>

+ 106
- 1
web_src/js/index.js View File

@@ -1222,10 +1222,18 @@ async function initRepository() {
highlight(this);
});
}
let imageShow = ''
const $content = $segment.parent();
if (!$content.find('.ui.small.images').length) {
if (data.attachments !== '') {

if ($content.find('.ui.middle.aligned').length === 0) {
imageShow += '<div class="ui clearing divider"></div>'
imageShow += '<div class="ui middle aligned padded grid">'
imageShow += data.attachments
imageShow += '</div>'
$content.find('.ui.attached.segment').append(imageShow)
}
else { $content.find('.ui.middle.aligned').html(data.attachments) }
}
} else if (data.attachments === '') {
$content
@@ -5070,3 +5078,100 @@ function initcreateRepo() {
}

initcreateRepo()


function initChartsNpu() {
const url = window.location.href
const urlArr = url.split('/')
let userName = urlArr.slice(-5)[0]
let repoPath = urlArr.slice(-4)[0]
let jobID = urlArr.slice(-1)[0]


let options = {
legend: {
data: []
},
grid: {
top: '30%',
bottom: '2%',
containLabel: true
},
tooltip: {
trigger: 'axis',
backgroundColor: 'rgb(51, 56, 84)',
borderColor: 'rgb(51, 51, 51)',
borderWidth: 0,
textStyle: {
color: '#fff'
},
axisPointer: {
type: 'line'
}
},
xAxis: {
type: 'category',
data: [],
boundaryGap: false,
axisLabel: {
interval: 'auto'
},
name: '时间(min)'
},
yAxis: {
min: 0,
max: 100,
show: true,
name: '占有率(%)',
axisLine: {
show: true
},
axisTick: { show: true }
},

series: []
};
$('.metric_chart').click(function (e) {
let versionName = $(this).data('version')
console.log("11111", versionName)
let myCharts = echarts.init(document.getElementById(`metric-${versionName}`))
$.get(`${window.config.AppSubUrl}/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/metric_statistics?version_name=${versionName}&statistic_type=each`, (res) => {
let filterDta = res.MetricsInfo.filter((item) => {

return !(['recvBytesRate', 'diskWriteRate', 'sendBytesRate', 'diskReadRate'].includes(item.metric))
})
let legenData = filterDta.map((item) => {
return item.metric
})
let seriesData = filterDta.map((item) => {
let seriesOption = {
name: item.metric,
type: 'line',
symbol: 'circle',
symbolSize: 10,
smooth: true,
showSymbol: false,
lineStyle: {
width: 2,
shadowColor: 'rgba(0,0,0,0.3)',
shadowBlur: 10,
shadowOffsetY: 8
},
data: item.value
}
return seriesOption
})
let xLength = res.MetricsInfo[0].value.length
console.log(legenData)
options.xAxis.data = Array.from({ length: xLength }, (_, index) => index + 1)
options.legend.data = legenData
options.series = seriesData
options && myCharts.setOption(options);

})
options && myCharts.setOption(options);

})
}

initChartsNpu()

Loading…
Cancel
Save