Browse Source

Merge pull request 'trainjob fix bug' (#967) from liuzx_trainjob into V20211115

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/967
tags/v1.21.12.1
lewis 4 years ago
parent
commit
ebc09452d0
8 changed files with 29 additions and 17 deletions
  1. +11
    -3
      routers/repo/modelarts.go
  2. +1
    -1
      templates/repo/create.tmpl
  3. +1
    -1
      templates/repo/migrate.tmpl
  4. +1
    -3
      templates/repo/modelarts/trainjob/show.tmpl
  5. +12
    -6
      templates/repo/modelarts/trainjob/version_new.tmpl
  6. +1
    -1
      templates/repo/pulls/fork.tmpl
  7. +1
    -1
      templates/repo/settings/options.tmpl
  8. +1
    -1
      templates/user/settings/profile.tmpl

+ 11
- 3
routers/repo/modelarts.go View File

@@ -479,12 +479,12 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error {
ctx.Data["PageIsCloudBrain"] = true
var jobID = ctx.Params(":jobid")
var versionName = ctx.Query("version_name")

// canNewJob, err := canUserCreateTrainJobVersion(ctx, jobID, versionName)
// if err != nil {
// ctx.ServerError("canNewJob can info failed", err)
// return err
// }
// ctx.Data["canNewJob"] = canNewJob

task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName)
if err != nil {
@@ -643,6 +643,7 @@ func VersionErrorDataPrepare(ctx *context.Context, form auth.CreateModelArtsTrai
ctx.Data["engine_name"] = form.EngineName
ctx.Data["flavor_code"] = task.FlavorCode
ctx.Data["engine_id"] = task.EngineID
ctx.Data["version_name"] = form.VersionName

ctx.Data["bootFile"] = form.BootFile
ctx.Data["uuid"] = form.Attachment
@@ -881,6 +882,13 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ
EngineName := form.EngineName
isLatestVersion := modelarts.IsLatestVersion

//判断权限
canNewJob, _ := canUserCreateTrainJobVersion(ctx, latestTask.UserID)
if !canNewJob {
ctx.RenderWithErr("user cann't new trainjob", tplModelArtsTrainJobVersionNew, &form)
return
}

if err := paramCheckCreateTrainJob(form); err != nil {
log.Error("paramCheckCreateTrainJob failed:(%v)", err)
VersionErrorDataPrepare(ctx, form)
@@ -927,6 +935,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ
}

parentDir := VersionOutputPath + "/"
// parentDir := ""
// if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil {
if err := uploadCodeToObs(codeLocalPath, jobName, parentDir); err != nil {
log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err)
@@ -1183,7 +1192,7 @@ func TrainJobShow(ctx *context.Context) {
if len(parameters.Parameter) > 0 {
paramTemp := ""
for _, Parameter := range parameters.Parameter {
param := Parameter.Label + " = " + Parameter.Value + ", "
param := Parameter.Label + " = " + Parameter.Value + "; "
paramTemp = paramTemp + param
}
VersionListTasks[i].Parameters = paramTemp[:len(paramTemp)-2]
@@ -1328,7 +1337,6 @@ func canUserCreateTrainJobVersion(ctx *context.Context, userID int64) (bool, err
return true, nil
} else {
log.Error("Only user itself and admin can new trainjob!")
// ctx.ServerError("Only user itself and admin can new trainjob!", nil)
return false, nil
}
}


+ 1
- 1
templates/repo/create.tmpl View File

@@ -54,7 +54,7 @@
</div>
<div class="inline field {{if .Err_Description}}error{{end}}">
<label for="description">{{.i18n.Tr "repo.repo_desc"}}</label>
<textarea id="description" name="description">{{.description}}</textarea>
<textarea id="description" name="description" maxlength="255">{{.description}}</textarea>
</div>
<div class="inline field">
<label>{{.i18n.Tr "repo.template"}}</label>


+ 1
- 1
templates/repo/migrate.tmpl View File

@@ -122,7 +122,7 @@
</div>
<div class="inline field {{if .Err_Description}}error{{end}}">
<label for="description">{{.i18n.Tr "repo.repo_desc"}}</label>
<textarea id="description" name="description">{{.description}}</textarea>
<textarea id="description" name="description" maxlength="255">{{.description}}</textarea>
</div>

<div class="inline field">


+ 1
- 3
templates/repo/modelarts/trainjob/show.tmpl View File

@@ -549,7 +549,6 @@ td, th {

function refreshStatus(version_name){
$.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}?version_name=${version_name}`,(data)=>{
console.log(data)
// header status and duration
$(`#${version_name}-duration-span`).text(data.JobDuration)
$(`#${version_name}-status-span span`).text(data.JobStatus)
@@ -714,8 +713,7 @@ td, th {
let scrollTop = container.scrollTop
let scrollHeight = container.scrollHeight
let clientHeight = container.clientHeight
if(parseInt(scrollTop) + clientHeight == scrollHeight && scrollHeight>clientHeight){
if(parseInt(scrollTop) + clientHeight == scrollHeight || parseInt(scrollTop) + clientHeight +1 == scrollHeight || parseInt(scrollTop) + clientHeight - 1 == scrollHeight){
let end_line = $(`#log${version_name} input[name=end_line]`).val()
$.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&base_line=${end_line}&lines=50&order=desc`, (data) => {
if (data.Lines == 0){


+ 12
- 6
templates/repo/modelarts/trainjob/version_new.tmpl View File

@@ -156,7 +156,11 @@
<form class="ui form" action="{{$.RepoLink}}/modelarts/train-job/{{.JobID}}/create_version" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="update">
{{if .version_name}}
<input type="hidden" name="version_name" value="{{.version_name}}">
{{else}}
<input type="hidden" name="version_name" value="">
{{end}}
<input type="hidden" id="ai_engine_name" name="engine_names" value="">
<input type="hidden" id="ai_flaver_name" name="flaver_names" value="">
<h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4>
@@ -167,8 +171,11 @@
</div>
<div class="required unite min_title inline field">
<label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.parents_version"}}</label>
{{if .version_name}}
<input style="width: 60%;" value="{{.version_name}}" tabindex="3" disabled >
{{else}}
<input id="parents_version" style="width: 60%;" value="" tabindex="3" disabled >
{{end}}
</div>
<div class="unite min_title inline field">
@@ -521,8 +528,8 @@
identifier : 'run_para_list',
rules: [
{
type: 'maxLength[256]',
prompt : '所有字符最长不超过256个字符。'
type: 'maxLength[255]',
prompt : '所有字符最长不超过255个字符。'
}
]
},
@@ -578,8 +585,8 @@
identifier : 'run_para_list',
rules: [
{
type: 'maxLength[256]',
prompt : '所有字符最长不超过256个字符。'
type: 'maxLength[255]',
prompt : '所有字符最长不超过255个字符。'
}
]
},
@@ -614,7 +621,6 @@
function get_name(){
let name1=$("#engine_name .text").text()
let name2=$("#flaver_name .text").text()
console.log(name1,name2)
$("input#ai_engine_name").val(name1)
$("input#ai_flaver_name").val(name2)



+ 1
- 1
templates/repo/pulls/fork.tmpl View File

@@ -53,7 +53,7 @@
</div>
<div class="inline field {{if .Err_Description}}error{{end}}">
<label for="description">{{.i18n.Tr "repo.repo_desc"}}</label>
<textarea id="description" name="description">{{.description}}</textarea>
<textarea id="description" name="description" maxlength="255">{{.description}}</textarea>
</div>

<div class="inline field">


+ 1
- 1
templates/repo/settings/options.tmpl View File

@@ -41,7 +41,7 @@
{{end}}
<div class="field {{if .Err_Description}}error{{end}}">
<label for="description">{{$.i18n.Tr "repo.repo_desc"}}</label>
<textarea id="description" name="description" rows="2">{{.Repository.Description}}</textarea>
<textarea id="description" name="description" rows="2" maxlength="255">{{.Repository.Description}}</textarea>
</div>
<div class="field {{if .Err_Website}}error{{end}}">
<label for="website">{{.i18n.Tr "repo.settings.site"}}</label>


+ 1
- 1
templates/user/settings/profile.tmpl View File

@@ -34,7 +34,7 @@
</div>
<div class="field {{if .Err_Description}}error{{end}}">
<label for="description">{{$.i18n.Tr "user.user_bio"}}</label>
<textarea id="description" name="description" rows="2">{{.SignedUser.Description}}</textarea>
<textarea id="description" name="description" rows="2" maxlength="255">{{.SignedUser.Description}}</textarea>
</div>
<div class="field {{if .Err_Website}}error{{end}}">
<label for="website">{{.i18n.Tr "settings.website"}}</label>


Loading…
Cancel
Save