Browse Source

Merge branch 'V20211101' of git.openi.org.cn:OpenI/aiforge into fix-683

tags/v1.21.12.1
lewis 4 years ago
parent
commit
eb0f69907d
8 changed files with 118 additions and 37 deletions
  1. +1
    -1
      models/attachment.go
  2. +9
    -1
      models/cloudbrain.go
  3. +2
    -5
      models/file_chunk.go
  4. +3
    -3
      modules/modelarts/modelarts.go
  5. +14
    -8
      routers/repo/attachment.go
  6. +4
    -2
      routers/repo/modelarts.go
  7. +1
    -1
      templates/repo/modelarts/trainjob/index.tmpl
  8. +84
    -16
      templates/repo/modelarts/trainjob/new.tmpl

+ 1
- 1
models/attachment.go View File

@@ -379,7 +379,7 @@ func GetUnDecompressAttachments() ([]*Attachment, error) {


func getUnDecompressAttachments(e Engine) ([]*Attachment, error) { func getUnDecompressAttachments(e Engine) ([]*Attachment, error) {
attachments := make([]*Attachment, 0, 10) attachments := make([]*Attachment, 0, 10)
return attachments, e.Where("decompress_state = ? and dataset_id != 0 and attachment.type = ? and (name like '%.zip' or name like '%.tar.gz' or name like '%.tgz')", DecompressStateInit, TypeCloudBrainOne).Find(&attachments)
return attachments, e.Where("decompress_state = ? and dataset_id != 0 and (name like '%.zip' or name like '%.tar.gz' or name like '%.tgz')", DecompressStateInit).Find(&attachments)
} }


func GetAllPublicAttachments() ([]*AttachmentUsername, error) { func GetAllPublicAttachments() ([]*AttachmentUsername, error) {


+ 9
- 1
models/cloudbrain.go View File

@@ -29,6 +29,7 @@ const (
JobTypeBenchmark JobType = "BENCHMARK" JobTypeBenchmark JobType = "BENCHMARK"
JobTypeSnn4imagenet JobType = "SNN4IMAGENET" JobTypeSnn4imagenet JobType = "SNN4IMAGENET"
JobTypeBrainScore JobType = "BRAINSCORE" JobTypeBrainScore JobType = "BRAINSCORE"
JobTypeTrain JobType = "TRAIN"


ModelArtsCreateQueue ModelArtsJobStatus = "CREATE_QUEUING" //免费资源创建排队中 ModelArtsCreateQueue ModelArtsJobStatus = "CREATE_QUEUING" //免费资源创建排队中
ModelArtsCreating ModelArtsJobStatus = "CREATING" //创建中 ModelArtsCreating ModelArtsJobStatus = "CREATING" //创建中
@@ -153,7 +154,8 @@ type CloudbrainsOptions struct {
SortType string SortType string
CloudbrainIDs []int64 CloudbrainIDs []int64
// JobStatus CloudbrainStatus // JobStatus CloudbrainStatus
Type int
Type int
JobType string
} }
type TaskPod struct { type TaskPod struct {
TaskRoleStatus struct { TaskRoleStatus struct {
@@ -846,6 +848,12 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) {
) )
} }


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

// switch opts.JobStatus { // switch opts.JobStatus {
// case JobWaiting: // case JobWaiting:
// cond.And(builder.Eq{"cloudbrain.status": int(JobWaiting)}) // cond.And(builder.Eq{"cloudbrain.status": int(JobWaiting)})


+ 2
- 5
models/file_chunk.go View File

@@ -14,11 +14,8 @@ const (
) )


const ( const (
TypeCloudBrainOne = 0
TypeCloudBrainNotebook = 1
TypeCloudBrainTrainJob = 2

TypeCloudBrainTwo = 1
TypeCloudBrainOne int = iota
TypeCloudBrainTwo
) )


type FileChunk struct { type FileChunk struct {


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

@@ -159,7 +159,7 @@ func GenerateTask(ctx *context.Context, jobName, uuid, description string) error
JobID: jobResult.ID, JobID: jobResult.ID,
JobName: jobName, JobName: jobName,
JobType: string(models.JobTypeDebug), JobType: string(models.JobTypeDebug),
Type: models.TypeCloudBrainNotebook,
Type: models.TypeCloudBrainTwo,
Uuid: uuid, Uuid: uuid,
}) })


@@ -207,8 +207,8 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) error {
RepoID: ctx.Repo.Repository.ID, RepoID: ctx.Repo.Repository.ID,
JobID: strconv.FormatInt(jobResult.JobID, 10), JobID: strconv.FormatInt(jobResult.JobID, 10),
JobName: req.JobName, JobName: req.JobName,
JobType: string(models.JobTypeDebug),
Type: models.TypeCloudBrainTrainJob,
JobType: string(models.JobTypeTrain),
Type: models.TypeCloudBrainTwo,
VersionID: jobResult.VersionID, VersionID: jobResult.VersionID,
VersionName: jobResult.VersionName, VersionName: jobResult.VersionName,
Uuid: req.Uuid, Uuid: req.Uuid,


+ 14
- 8
routers/repo/attachment.go View File

@@ -917,16 +917,22 @@ func HandleUnDecompressAttachment() {
} }


for _, attach := range attachs { for _, attach := range attachs {
err = worker.SendDecompressTask(contexExt.Background(), attach.UUID, attach.Name)
if err != nil {
log.Error("SendDecompressTask(%s) failed:%s", attach.UUID, err.Error())
} else {
attach.DecompressState = models.DecompressStateIng
err = models.UpdateAttachment(attach)
if attach.Type == models.TypeCloudBrainOne {
err = worker.SendDecompressTask(contexExt.Background(), attach.UUID, attach.Name)
if err != nil { if err != nil {
log.Error("UpdateAttachment state(%s) failed:%s", attach.UUID, err.Error())
log.Error("SendDecompressTask(%s) failed:%s", attach.UUID, err.Error())
} else {
attach.DecompressState = models.DecompressStateIng
err = models.UpdateAttachment(attach)
if err != nil {
log.Error("UpdateAttachment state(%s) failed:%s", attach.UUID, err.Error())
}
} }
} else if attach.Type == models.TypeCloudBrainTwo {
attachjson, _ := json.Marshal(attach)
labelmsg.SendDecompressAttachToLabelOBS(string(attachjson))
} }

} }


return return
@@ -1014,7 +1020,7 @@ func queryDatasets(ctx *context.Context, attachs []*models.AttachmentUsername) {
} }


func checkTypeCloudBrain(typeCloudBrain int) error { func checkTypeCloudBrain(typeCloudBrain int) error {
if typeCloudBrain != models.TypeCloudBrainOne && typeCloudBrain != models.TypeCloudBrainNotebook {
if typeCloudBrain != models.TypeCloudBrainOne && typeCloudBrain != models.TypeCloudBrainTwo {
log.Error("type error:", typeCloudBrain) log.Error("type error:", typeCloudBrain)
return errors.New("type error") return errors.New("type error")
} }


+ 4
- 2
routers/repo/modelarts.go View File

@@ -287,7 +287,8 @@ func NotebookIndex(ctx *context.Context) {
PageSize: setting.UI.IssuePagingNum, PageSize: setting.UI.IssuePagingNum,
}, },
RepoID: repo.ID, RepoID: repo.ID,
Type: models.TypeCloudBrainNotebook,
Type: models.TypeCloudBrainTwo,
JobType: string(models.JobTypeDebug),
}) })
if err != nil { if err != nil {
ctx.ServerError("Cloudbrain", err) ctx.ServerError("Cloudbrain", err)
@@ -512,7 +513,8 @@ func TrainJobIndex(ctx *context.Context) {
PageSize: setting.UI.IssuePagingNum, PageSize: setting.UI.IssuePagingNum,
}, },
RepoID: repo.ID, RepoID: repo.ID,
Type: models.TypeCloudBrainTrainJob,
Type: models.TypeCloudBrainTwo,
JobType: string(models.JobTypeTrain),
}) })
if err != nil { if err != nil {
ctx.ServerError("Cloudbrain", err) ctx.ServerError("Cloudbrain", err)


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

@@ -355,7 +355,7 @@
<form id="stopForm-{{.JobID}}" action="{{$.Link}}/{{.JobID}}/stop" method="post" style="margin-left:-1px;"> <form id="stopForm-{{.JobID}}" action="{{$.Link}}/{{.JobID}}/stop" method="post" style="margin-left:-1px;">
{{$.CsrfTokenHtml}} {{$.CsrfTokenHtml}}
{{if $.Permission.CanWrite $.UnitTypeCloudBrain}} {{if $.Permission.CanWrite $.UnitTypeCloudBrain}}
<a id="stop-model-debug-{{.JobID}}" class="ui basic {{if eq .Status "KILLED" "FAILED" "START_FAILED" "KILLING"}}disabled {{else}}blue {{end}}button" onclick="document.getElementById('stopForm-{{.JobID}}').submit();">
<a id="stop-model-debug-{{.JobID}}" class="ui basic {{if eq .Status "KILLED" "FAILED" "START_FAILED" "KILLING" "COMPLETED"}}disabled {{else}}blue {{end}}button" onclick="document.getElementById('stopForm-{{.JobID}}').submit();">
{{$.i18n.Tr "repo.stop"}} {{$.i18n.Tr "repo.stop"}}
</a> </a>
{{else}} {{else}}


+ 84
- 16
templates/repo/modelarts/trainjob/new.tmpl View File

@@ -156,13 +156,9 @@
<h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4> <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4>
<div class="required unite min_title inline field"> <div class="required unite min_title inline field">
<label>{{.i18n.Tr "repo.modelarts.train_job.job_name"}}</label> <label>{{.i18n.Tr "repo.modelarts.train_job.job_name"}}</label>
<input style="width: 80%;" name="job_name" id="trainjob_job_name" placeholder={{.i18n.Tr "repo.modelarts.train_job.job_name"}} value="{{.job_name}}" tabindex="3" autofocus required maxlength="255">
<input style="width: 60%;" name="job_name" id="trainjob_job_name" placeholder={{.i18n.Tr "repo.modelarts.train_job.job_name"}} value="{{.job_name}}" tabindex="3" autofocus required maxlength="255">
</div> </div>
<!--<div class="inline field">
<label>{{.i18n.Tr "repo.modelarts.train_job.version"}}</label>
<span>第一版本</span>
</div>
-->
<div class="unite min_title inline field"> <div class="unite min_title inline field">
<label for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}&nbsp;&nbsp;</label> <label for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}&nbsp;&nbsp;</label>
<textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} onchange="this.value=this.value.substring(0, 255)" onkeydown="this.value=this.value.substring(0, 255)" onkeyup="this.value=this.value.substring(0, 256)"></textarea> <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} onchange="this.value=this.value.substring(0, 255)" onkeydown="this.value=this.value.substring(0, 255)" onkeyup="this.value=this.value.substring(0, 256)"></textarea>
@@ -182,7 +178,7 @@
<div class="required unite min_title inline fields" style="width: 90%;"> <div class="required unite min_title inline fields" style="width: 90%;">
<label>{{.i18n.Tr "repo.modelarts.train_job.AI_driver"}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label> <label>{{.i18n.Tr "repo.modelarts.train_job.AI_driver"}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
<div class="field" style="flex: 1.5;"> <div class="field" style="flex: 1.5;">
<select class="ui search dropdown width" id="trainjob_engines" >
<select class="ui dropdown width" id="trainjob_engines" >
{{range .engines}} {{range .engines}}
<option value="{{.Value}}">{{.Value}}</option> <option value="{{.Value}}">{{.Value}}</option>
{{end}} {{end}}
@@ -190,7 +186,7 @@


</div> </div>
<div class="field" style="flex: 2;"> <div class="field" style="flex: 2;">
<select class="ui search dropdown width" id="trainjob_engine_versions" style='width: 100%;' name="engine_id">
<select class="ui dropdown width" id="trainjob_engine_versions" style='width: 100%;' name="engine_id">
{{range .engine_versions}} {{range .engine_versions}}
<option name="engine_id" value="{{.ID}}">{{.Value}}</option> <option name="engine_id" value="{{.ID}}">{{.Value}}</option>
{{end}} {{end}}
@@ -246,16 +242,17 @@
</div> </div>
<div class="required unite min_title inline field"> <div class="required unite min_title inline field">
<label>{{.i18n.Tr "repo.modelarts.train_job.dataset"}}</label> <label>{{.i18n.Tr "repo.modelarts.train_job.dataset"}}</label>
<select class="ui search dropdown width80" id="trainjob_datasets" name="attachment">
<select class="ui dropdown width80" id="trainjob_datasets" name="attachment" placeholder="选择数据集">
{{if $.uuid}} {{if $.uuid}}
<option name="attachment" value="{{$.uuid}}">{{$.datasetName}}</option> <option name="attachment" value="{{$.uuid}}">{{$.datasetName}}</option>
{{end}} {{end}}
{{range .attachments}} {{range .attachments}}
<option value="">选择数据集</option>
<option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option> <option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option>
{{end}} {{end}}
</select> </select>
</div> </div>
<div class="inline unite min_title field"> <div class="inline unite min_title field">
<label>{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label> <label>{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label>
<!-- <i class="plus square outline icon"></i> --> <!-- <i class="plus square outline icon"></i> -->
@@ -270,7 +267,7 @@
<!-- <h4 class="ui dividing header">{{.i18n.Tr "repo.modelarts.train_job.resource_setting"}}</h4> --> <!-- <h4 class="ui dividing header">{{.i18n.Tr "repo.modelarts.train_job.resource_setting"}}</h4> -->
<div class="required field " style="display: none;"> <div class="required field " style="display: none;">
<label>{{.i18n.Tr "repo.modelarts.train_job.resource_pool"}}</label> <label>{{.i18n.Tr "repo.modelarts.train_job.resource_pool"}}</label>
<select class="ui search dropdown" id="trainjob_resource_pool" style='width:385px' name="pool_id">
<select class="ui dropdown" id="trainjob_resource_pool" style='width:385px' name="pool_id">
{{range .resource_pools}} {{range .resource_pools}}
<option value="{{.ID}}">{{.Value}}</option> <option value="{{.ID}}">{{.Value}}</option>
{{end}} {{end}}
@@ -295,7 +292,7 @@


<div class="required unite min_title inline field"> <div class="required unite min_title inline field">
<label>{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label> <label>{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label>
<select class="ui search dropdown width81" id="trainjob-flavor" style='width:385px' name="flavor">
<select class="ui dropdown width81" id="trainjob-flavor" style='width:385px' name="flavor">
{{range .flavor_infos}} {{range .flavor_infos}}
<option name="flavor" value="{{.Code}}">{{.Value}}</option> <option name="flavor" value="{{.Code}}">{{.Value}}</option>
{{end}} {{end}}
@@ -304,11 +301,11 @@
<div class="inline required unite min_title field"> <div class="inline required unite min_title field">
<label>{{.i18n.Tr "repo.modelarts.train_job.amount_of_compute_node"}}</label> <label>{{.i18n.Tr "repo.modelarts.train_job.amount_of_compute_node"}}</label>
<div class="ui labeled input">
<span class="min"><i class="minus icon"></i></span>
<input style="border-radius: 0;" name="work_server_number" id="trainjob_work_server_num" tabindex="3" autofocus required maxlength="255" value="1">
<div class="ui labeled input" style="width: 5%;">
<!-- <span class="min"><i class="minus icon"></i></span> -->
<input style="border-radius: 0;text-align: center;" name="work_server_number" id="trainjob_work_server_num" tabindex="3" autofocus required maxlength="255" value="1" readonly>
<span class="add"><i class="plus icon"></i></span>
<!-- <span class="add"><i class="plus icon"></i></span> -->
</div> </div>
<!-- <input name="work_server_number" id="trainjob_work_server_num" tabindex="3" autofocus required maxlength="255"> --> <!-- <input name="work_server_number" id="trainjob_work_server_num" tabindex="3" autofocus required maxlength="255"> -->
</div> </div>
@@ -363,6 +360,9 @@
let sever_num = $('#trainjob_work_server_num') let sever_num = $('#trainjob_work_server_num')
$('.add').click(function(){ $('.add').click(function(){
sever_num.val(parseInt(sever_num.val())+1) sever_num.val(parseInt(sever_num.val())+1)
if(sever_num.val()>=26){
sever_num.val(parseInt(sever_num.val())-1)
}
}) })
$('.min').click(function(){ $('.min').click(function(){
sever_num.val(parseInt(sever_num.val())-1) sever_num.val(parseInt(sever_num.val())-1)
@@ -478,6 +478,55 @@
$('.ui.parameter.modal') $('.ui.parameter.modal')
.modal('hide'); .modal('hide');
}) })
$('select.dropdown')
.dropdown();

$('.ui.form')
.form({
on: 'blur',
inline:true,
fields: {
boot_file: {
identifier : 'boot_file',
rules: [
{
type: 'regExp[/.+\.py$/g]',
prompt : '启动文件必须为.py结尾'
}
]
},
job_name:{
identifier : 'job_name',
rules: [
{
type: 'regExp[/^[a-zA-Z0-9-_]{1,36}$/]',
prompt : '只包含大小写字母、数字、_和-,最长36个字符。'
}
]
},
attachment:{
identifier : 'attachment',
rules: [
{
type: 'empty',
prompt : '选择一个数据集'
}
]

},
work_server_number: {
identifier : 'work_server_number',
rules: [
{
type : 'integer[1..25]',
prompt : '计算节点需要在1-25之间,请您键入正确的值'
}
]
}
},
})




function validate(){ function validate(){
$('.ui.form') $('.ui.form')
@@ -494,6 +543,25 @@
} }
] ]
}, },
job_name:{
identifier : 'job_name',
rules: [
{
type: 'regExp[/^[a-zA-Z0-9-_]{1,36}$/]',
prompt : '只包含大小写字母、数字、_和-,最长36个字符。'
}
]
},
attachment:{
identifier : 'attachment',
rules: [
{
type: 'empty',
prompt : '选择一个数据集'
}
]

},
work_server_number: { work_server_number: {
identifier : 'work_server_number', identifier : 'work_server_number',
rules: [ rules: [


Loading…
Cancel
Save