Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/2926 Reviewed-by: zhoupzh <zhoupzh@pcl.ac.cn>tags/v1.22.9.2^2
| @@ -1,6 +1,10 @@ | |||
| package dataset | |||
| import "code.gitea.io/gitea/models" | |||
| import ( | |||
| "strings" | |||
| "code.gitea.io/gitea/models" | |||
| ) | |||
| func GetResourceType(cloudbrainType int) string { | |||
| if cloudbrainType == 0 { | |||
| @@ -33,3 +37,23 @@ func IsShowDataSetOfCurrentRepo(repoID int64) bool { | |||
| return true | |||
| } | |||
| func GetFilterDeletedAttachments(uuids string) (string, string) { | |||
| attachments, err := models.GetAttachmentsByUUIDs(strings.Split(uuids, ";")) | |||
| if err != nil { | |||
| return "", "" | |||
| } | |||
| uuidR := "" | |||
| filenames := "" | |||
| for i, attachment := range attachments { | |||
| if i == 0 { | |||
| uuidR += attachment.UUID | |||
| filenames += attachment.Name | |||
| } else { | |||
| uuidR += ";" + attachment.UUID | |||
| filenames += ";" + attachment.Name | |||
| } | |||
| } | |||
| return uuidR, filenames | |||
| } | |||
| @@ -15,6 +15,8 @@ import ( | |||
| "time" | |||
| "unicode/utf8" | |||
| "code.gitea.io/gitea/modules/dataset" | |||
| "code.gitea.io/gitea/services/cloudbrain/resource" | |||
| "code.gitea.io/gitea/services/reward/point/account" | |||
| @@ -158,16 +160,10 @@ func cloudBrainNewDataPrepare(ctx *context.Context) error { | |||
| ctx.Data["model_version"] = ctx.Cloudbrain.ModelVersion | |||
| ctx.Data["pre_train_model_url"] = ctx.Cloudbrain.PreTrainModelUrl | |||
| ctx.Data["compute_resource"] = ctx.Cloudbrain.ComputeResource | |||
| ctx.Data["attachment"] = ctx.Cloudbrain.Uuid | |||
| uuids, datasetNames := dataset.GetFilterDeletedAttachments(ctx.Cloudbrain.Uuid) | |||
| ctx.Data["attachment"] = uuids | |||
| ctx.Data["dataset_name"] = datasetNames | |||
| ctx.Data["cluster_type"] = models.OpenICluster | |||
| _, _, datasetNames, _, err := getDatasUrlListByUUIDS(ctx.Cloudbrain.Uuid) | |||
| if err != nil { | |||
| log.Info("query dataset error," + err.Error()) | |||
| ctx.Data["dataset_name"] = "" | |||
| } else { | |||
| ctx.Data["dataset_name"] = datasetNames | |||
| } | |||
| } | |||
| return nil | |||
| @@ -12,6 +12,8 @@ import ( | |||
| "strings" | |||
| "time" | |||
| "code.gitea.io/gitea/modules/dataset" | |||
| "code.gitea.io/gitea/services/cloudbrain/resource" | |||
| "code.gitea.io/gitea/services/reward/point/account" | |||
| @@ -141,20 +143,21 @@ func grampusTrainJobNewDataPrepare(ctx *context.Context, processType string) err | |||
| } | |||
| if ctx.Cloudbrain != nil { | |||
| ctx.Data["attachment"] = ctx.Cloudbrain.Uuid | |||
| uuids, datasetNames := dataset.GetFilterDeletedAttachments(ctx.Cloudbrain.Uuid) | |||
| ctx.Data["attachment"] = uuids | |||
| ctx.Data["boot_file"] = ctx.Cloudbrain.BootFile | |||
| ctx.Data["image_id"] = ctx.Cloudbrain.ImageID | |||
| ctx.Data["run_para_list"] = ctx.Cloudbrain.Parameters | |||
| ctx.Data["description"] = ctx.Cloudbrain.Description | |||
| ctx.Data["branch_name"] = ctx.Cloudbrain.BranchName | |||
| ctx.Data["engine_name"] = ctx.Cloudbrain.EngineName | |||
| ctx.Data["WorkServerNumber"] = ctx.Cloudbrain.WorkServerNumber | |||
| ctx.Data["work_server_number"] = ctx.Cloudbrain.WorkServerNumber | |||
| if ctx.Cloudbrain.Image != "" { | |||
| ctx.Data["image"] = ctx.Cloudbrain.Image | |||
| } else { | |||
| ctx.Data["image"] = ctx.Cloudbrain.EngineName | |||
| } | |||
| ctx.Data["dataset_name"] = ctx.Cloudbrain.DatasetName | |||
| ctx.Data["dataset_name"] = datasetNames | |||
| ctx.Data["model_name"] = ctx.Cloudbrain.ModelName | |||
| ctx.Data["model_version"] = ctx.Cloudbrain.ModelVersion | |||
| @@ -15,6 +15,8 @@ import ( | |||
| "time" | |||
| "unicode/utf8" | |||
| "code.gitea.io/gitea/modules/dataset" | |||
| "code.gitea.io/gitea/modules/modelarts_cd" | |||
| "code.gitea.io/gitea/services/cloudbrain/resource" | |||
| "code.gitea.io/gitea/services/reward/point/account" | |||
| @@ -931,14 +933,11 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error { | |||
| ctx.ServerError("GetBranches error:", err) | |||
| return err | |||
| } | |||
| _, _, datasetNames, _, err := getDatasUrlListByUUIDS(task.Uuid) | |||
| if err != nil { | |||
| log.Info("query dataset error," + err.Error()) | |||
| //ctx.ServerError("GetAllUserAttachments failed:", err) | |||
| //return err | |||
| } else { | |||
| ctx.Data["dataset_name"] = datasetNames | |||
| } | |||
| uuids, datasetNames := dataset.GetFilterDeletedAttachments(task.Uuid) | |||
| ctx.Data["dataset_name"] = datasetNames | |||
| ctx.Data["branches"] = branches | |||
| ctx.Data["branch_name"] = task.BranchName | |||
| ctx.Data["description"] = task.Description | |||
| @@ -947,7 +946,7 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error { | |||
| ctx.Data["work_server_number"] = task.WorkServerNumber | |||
| ctx.Data["flavor_name"] = task.FlavorName | |||
| ctx.Data["engine_name"] = task.EngineName | |||
| ctx.Data["attachment"] = task.Uuid | |||
| ctx.Data["attachment"] = uuids | |||
| ctx.Data["flavor_code"] = task.FlavorCode | |||
| ctx.Data["engine_id"] = task.EngineID | |||
| ctx.Data["datasetType"] = models.TypeCloudBrainTwo | |||
| @@ -355,23 +355,32 @@ | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.resource_type"}} | |||
| {{$.i18n.Tr "repo.modelarts.model_name"}} | |||
| </td> | |||
| <td class="ti-text-form-content resorce_type"> | |||
| <div class="text-span text-span-w"></div> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w">{{if .ModelName}}{{.ModelName}}{{else}}--{{end}}</div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.standard"}} | |||
| {{$.i18n.Tr "repo.modelconvert.modelversion"}} | |||
| </td> | |||
| <td class="ti-text-form-content spec"> | |||
| <div class="text-span text-span-w"></div> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w">{{if .ModelVersion}}{{.ModelVersion}}{{else}}--{{end}}</div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.infer_job_model_file"}} | |||
| </td> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w">{{if .CkptName}}{{.CkptName}}{{else}}--{{end}}</div> | |||
| </td> | |||
| </tr> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| @@ -431,10 +440,28 @@ | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" title="{{.Parameters}}"> | |||
| {{.Parameters}} | |||
| {{if .Parameters}}{{.Parameters}}{{else}}--{{end}} | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.resource_type"}} | |||
| </td> | |||
| <td class="ti-text-form-content resorce_type"> | |||
| <div class="text-span text-span-w"></div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.standard"}} | |||
| </td> | |||
| <td class="ti-text-form-content spec"> | |||
| <div class="text-span text-span-w"></div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| @@ -443,7 +470,7 @@ | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" title="{{.Description}}"> | |||
| {{.Description}} | |||
| {{if .Description}}{{.Description}}{{else}}--{{end}} | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| @@ -319,7 +319,7 @@ | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w"> | |||
| {{.VersionName}} | |||
| {{if .VersionName}}{{.VersionName}}{{else}}--{{end}} | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| @@ -351,23 +351,32 @@ | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.standard"}} | |||
| {{$.i18n.Tr "repo.modelarts.model_name"}} | |||
| </td> | |||
| <td class="ti-text-form-content spec"> | |||
| <div class="text-span text-span-w"></div> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w">{{if .ModelName}}{{.ModelName}}{{else}}--{{end}}</div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.compute_node"}} | |||
| {{$.i18n.Tr "repo.modelconvert.modelversion"}} | |||
| </td> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w"> | |||
| {{.WorkServerNumber}} | |||
| </div> | |||
| <div class="text-span text-span-w">{{if .ModelVersion}}{{.ModelVersion}}{{else}}--{{end}}</div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.infer_job_model_file"}} | |||
| </td> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w">{{if .CkptName}}{{.CkptName}}{{else}}--{{end}}</div> | |||
| </td> | |||
| </tr> | |||
| </tbody> | |||
| @@ -408,47 +417,48 @@ | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.train_dataset"}} | |||
| {{$.i18n.Tr "repo.modelarts.train_job.run_parameter"}} | |||
| </td> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w"> | |||
| {{range $m ,$n := $.datasetDownload}} | |||
| {{if eq .IsDelete true}} | |||
| {{.DatasetName}}({{$.i18n.Tr "dataset.file_deleted"}}) | |||
| {{else}} | |||
| <a href="{{.RepositoryLink}}" target="_blank">{{.DatasetName}}</a> | |||
| {{end}} | |||
| {{end}} | |||
| <div class="text-span text-span-w" title="{{.Parameters}}"> | |||
| {{if .Parameters}}{{.Parameters}}{{else}}--{{end}} | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.run_parameter"}} | |||
| {{$.i18n.Tr "repo.grampus.train_job.ai_center"}} | |||
| </td> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" title="{{.Parameters}}"> | |||
| {{.Parameters}} | |||
| <div class="text-span text-span-w" id="{{.VersionName}}-ai_center"> | |||
| {{if $.ai_center}}{{$.ai_center}}{{else}}--{{end}} | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.grampus.train_job.ai_center"}} | |||
| {{$.i18n.Tr "repo.modelarts.train_job.standard"}} | |||
| </td> | |||
| <td class="ti-text-form-content spec"> | |||
| <div class="text-span text-span-w"></div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.compute_node"}} | |||
| </td> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" id="{{.VersionName}}-ai_center"> | |||
| {{$.ai_center}} | |||
| <div class="text-span text-span-w"> | |||
| {{.WorkServerNumber}} | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.description"}} | |||
| @@ -457,7 +467,7 @@ | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" | |||
| title="{{.Description}}"> | |||
| {{.Description}} | |||
| {{if .Description}}{{.Description}}{{else}}--{{end}} | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| @@ -466,7 +476,26 @@ | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div style="clear:both"> | |||
| <table style="border:none" class="ui fixed small stackable table"> | |||
| <thead> | |||
| <tr><th style="color: #8a8e99;font-size:12px" class="three wide left aligned">{{$.i18n.Tr "dataset.file"}}</th> | |||
| </tr></thead> | |||
| <tbody> | |||
| {{range $m ,$n := $.datasetDownload}} | |||
| <tr> | |||
| <td style="word-wrap: break-word;word-break: break-all;"> | |||
| {{if eq .IsDelete true}} | |||
| {{.DatasetName}}({{$.i18n.Tr "dataset.file_deleted"}}) | |||
| {{else}} | |||
| <a href="{{.RepositoryLink}}" target="_blank">{{.DatasetName}}</a> | |||
| {{end}} | |||
| </td> | |||
| </tr> | |||
| {{end}} | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="ui tab" data-tab="second{{$k}}"> | |||
| @@ -393,28 +393,31 @@ | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.standard"}} | |||
| {{$.i18n.Tr "repo.modelarts.model_name"}} | |||
| </td> | |||
| <td class="ti-text-form-content spec{{$k}}"> | |||
| <div class="text-span text-span-w"></div> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w">{{if .ModelName}}{{.ModelName}}{{else}}--{{end}}</div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelconvert.modelversion"}} | |||
| </td> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w">{{if .ModelVersion}}{{.ModelVersion}}{{else}}--{{end}}</div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.infer_job_model_file"}} | |||
| </td> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w">{{if .CkptName}}{{.CkptName}}{{else}}--{{end}}</div> | |||
| </td> | |||
| <script> | |||
| ;(function() { | |||
| var SPEC = {{ .Spec }}; | |||
| var showPoint = false; | |||
| var specStr = window.renderSpecStr(SPEC, showPoint, { | |||
| gpu_memory: {{$.i18n.Tr "cloudbrain.gpu_memory"}}, | |||
| free: {{$.i18n.Tr "cloudbrain.free"}}, | |||
| point_hr: {{$.i18n.Tr "cloudbrain.point_hr"}}, | |||
| memory: {{$.i18n.Tr "cloudbrain.memory"}}, | |||
| shared_memory: {{$.i18n.Tr "cloudbrain.shared_memory"}}, | |||
| }); | |||
| $('td.ti-text-form-content.spec{{$k}} div').text(specStr); | |||
| })(); | |||
| </script> | |||
| </tr> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| @@ -461,22 +464,34 @@ | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" title="{{.Parameters}}"> | |||
| {{.Parameters}} | |||
| {{if .Parameters}}{{.Parameters}}{{else}}--{{end}} | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.description"}} | |||
| {{$.i18n.Tr "repo.modelarts.train_job.standard"}} | |||
| </td> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" | |||
| title="{{.Cloudbrain.Description}}"> | |||
| {{.Cloudbrain.Description}} | |||
| </div> | |||
| <td class="ti-text-form-content spec{{$k}}"> | |||
| <div class="text-span text-span-w"></div> | |||
| </td> | |||
| <script> | |||
| ;(function() { | |||
| var SPEC = {{ .Spec }}; | |||
| var showPoint = false; | |||
| var specStr = window.renderSpecStr(SPEC, showPoint, { | |||
| gpu_memory: {{$.i18n.Tr "cloudbrain.gpu_memory"}}, | |||
| free: {{$.i18n.Tr "cloudbrain.free"}}, | |||
| point_hr: {{$.i18n.Tr "cloudbrain.point_hr"}}, | |||
| memory: {{$.i18n.Tr "cloudbrain.memory"}}, | |||
| shared_memory: {{$.i18n.Tr "cloudbrain.shared_memory"}}, | |||
| }); | |||
| $('td.ti-text-form-content.spec{{$k}} div').text(specStr); | |||
| })(); | |||
| </script> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| @@ -488,6 +503,18 @@ | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| <tr class="ti-no-ng-animate"> | |||
| <td class="ti-no-ng-animate ti-text-form-label text-width80"> | |||
| {{$.i18n.Tr "repo.modelarts.train_job.description"}} | |||
| </td> | |||
| <td class="ti-text-form-content"> | |||
| <div class="text-span text-span-w" | |||
| title="{{.Cloudbrain.Description}}"> | |||
| {{if .Cloudbrain.Description}}{{.Cloudbrain.Description}}{{else}}--{{end}} | |||
| </div> | |||
| </td> | |||
| </tr> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| @@ -693,7 +720,6 @@ | |||
| <script type="text/javascript" src="/self/ztree/js/jquery.ztree.core.js"></script> | |||
| <script type="text/javascript" src="/self/ztree/js/jquery.ztree.excheck.js"></script> | |||
| <script> | |||
| var setting = { | |||
| check: { | |||
| @@ -1,161 +1,163 @@ | |||
| let form = document.getElementById("form_id"); | |||
| let createFlag = false; | |||
| let flag; | |||
| form.onsubmit = function (e) { | |||
| if (createFlag) return false; | |||
| createFlag = true; | |||
| }; | |||
| $("select.dropdown").dropdown(); | |||
| $(document).keydown(function (event) { | |||
| switch (event.keyCode) { | |||
| case 13: | |||
| return false; | |||
| } | |||
| }); | |||
| $(".menu .item").tab(); | |||
| $(document).ready(createParamter()); | |||
| function createParamter() { | |||
| let params = $(".dynamic.field").data("params"); | |||
| params && | |||
| params.parameter.forEach((item, index) => { | |||
| Add_parameter(index, (flag = true), item); | |||
| }); | |||
| } | |||
| // 参数增加、删除、修改、保存 | |||
| function Add_parameter(i, flag = false, paramsObject = {}) { | |||
| let value = ""; | |||
| value += `<div class="two fields width85" id= "para${i}">`; | |||
| value += '<div class="field">'; | |||
| let placeholder_value = $(".dynamic.field").data("params-value"); | |||
| let placeholder_name = $(".dynamic.field").data("params-name"); | |||
| if (flag) { | |||
| value += `<input type="text" class="shipping_first-name" value="${paramsObject.label}">`; | |||
| } else { | |||
| value += | |||
| '<input type="text" class="shipping_first-name" required placeholder="' + | |||
| placeholder_name + | |||
| '">'; | |||
| (function () { | |||
| let form = document.getElementById("form_id"); | |||
| let createFlag = false; | |||
| let flag; | |||
| form.onsubmit = function (e) { | |||
| if (createFlag) return false; | |||
| createFlag = true; | |||
| }; | |||
| $("select.dropdown").dropdown(); | |||
| $(document).keydown(function (event) { | |||
| switch (event.keyCode) { | |||
| case 13: | |||
| return false; | |||
| } | |||
| }); | |||
| $(".menu .item").tab(); | |||
| $(document).ready(createParamter()); | |||
| function createParamter() { | |||
| let params = $(".dynamic.field").data("params"); | |||
| params && | |||
| params.parameter.forEach((item, index) => { | |||
| Add_parameter(index, (flag = true), item); | |||
| }); | |||
| } | |||
| value += "</div>"; | |||
| value += '<div class="field">'; | |||
| if (flag) { | |||
| value += `<input type="text" class="shipping_last-name" value="${paramsObject.value}">`; | |||
| } else { | |||
| value += | |||
| '<input type="text" class="shipping_last-name" required placeholder="' + | |||
| placeholder_value + | |||
| '">'; | |||
| // 参数增加、删除、修改、保存 | |||
| function Add_parameter(i, flag = false, paramsObject = {}) { | |||
| let value = ""; | |||
| value += `<div class="two fields width85" id= "para${i}">`; | |||
| value += '<div class="field">'; | |||
| let placeholder_value = $(".dynamic.field").data("params-value"); | |||
| let placeholder_name = $(".dynamic.field").data("params-name"); | |||
| if (flag) { | |||
| value += `<input type="text" class="shipping_first-name" value="${paramsObject.label}">`; | |||
| } else { | |||
| value += | |||
| '<input type="text" class="shipping_first-name" required placeholder="' + | |||
| placeholder_name + | |||
| '">'; | |||
| } | |||
| value += "</div>"; | |||
| value += '<div class="field">'; | |||
| if (flag) { | |||
| value += `<input type="text" class="shipping_last-name" value="${paramsObject.value}">`; | |||
| } else { | |||
| value += | |||
| '<input type="text" class="shipping_last-name" required placeholder="' + | |||
| placeholder_value + | |||
| '">'; | |||
| } | |||
| value += "</div>"; | |||
| value += '<span><i class="trash icon"></i></span>'; | |||
| value += "</div>"; | |||
| $(".dynamic.field").append(value); | |||
| } | |||
| value += "</div>"; | |||
| value += '<span><i class="trash icon"></i></span>'; | |||
| value += "</div>"; | |||
| $(".dynamic.field").append(value); | |||
| } | |||
| $("#add_run_para").click(function () { | |||
| var len = $(".dynamic.field .two.fields").length; | |||
| Add_parameter(len); | |||
| }); | |||
| $("#add_run_para").click(function () { | |||
| var len = $(".dynamic.field .two.fields").length; | |||
| Add_parameter(len); | |||
| }); | |||
| $(".dynamic.field").on("click", ".trash.icon", function () { | |||
| var index = $(this).parent().parent().index(); | |||
| $(this).parent().parent().remove(); | |||
| var len = $(".dynamic.field .two.fields").length; | |||
| $(".dynamic.field .two.fields").each(function () { | |||
| var cur_index = $(this).index(); | |||
| $(this).attr("id", "para" + cur_index); | |||
| $(".dynamic.field").on("click", ".trash.icon", function () { | |||
| var index = $(this).parent().parent().index(); | |||
| $(this).parent().parent().remove(); | |||
| var len = $(".dynamic.field .two.fields").length; | |||
| $(".dynamic.field .two.fields").each(function () { | |||
| var cur_index = $(this).index(); | |||
| $(this).attr("id", "para" + cur_index); | |||
| }); | |||
| }); | |||
| }); | |||
| $(".question.circle.icon").hover(function () { | |||
| $(this).popup("show"); | |||
| }); | |||
| $(".question.circle.icon").hover(function () { | |||
| $(this).popup("show"); | |||
| }); | |||
| var isValidate = false; | |||
| function validate() { | |||
| $(".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个字符。", | |||
| }, | |||
| ], | |||
| }, | |||
| display_job_name: { | |||
| identifier: "display_job_name", | |||
| rules: [ | |||
| { | |||
| type: "regExp[/^[a-zA-Z0-9-_]{1,36}$/]", | |||
| prompt: "只包含大小写字母、数字、_和-,最长36个字符。", | |||
| }, | |||
| ], | |||
| var isValidate = false; | |||
| function validate() { | |||
| $(".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个字符。", | |||
| }, | |||
| ], | |||
| }, | |||
| display_job_name: { | |||
| identifier: "display_job_name", | |||
| rules: [ | |||
| { | |||
| type: "regExp[/^[a-zA-Z0-9-_]{1,36}$/]", | |||
| prompt: "只包含大小写字母、数字、_和-,最长36个字符。", | |||
| }, | |||
| ], | |||
| }, | |||
| attachment: { | |||
| identifier: "attachment", | |||
| rules: [ | |||
| { | |||
| type: "empty", | |||
| prompt: "选择一个数据集", | |||
| }, | |||
| ], | |||
| }, | |||
| spec_id: { | |||
| identifier: "spec_id", | |||
| rules: [{ type: "empty" }], | |||
| }, | |||
| }, | |||
| attachment: { | |||
| identifier: "attachment", | |||
| rules: [ | |||
| { | |||
| type: "empty", | |||
| prompt: "选择一个数据集", | |||
| }, | |||
| ], | |||
| onSuccess: function () { | |||
| // $('.ui.page.dimmer').dimmer('show') | |||
| document.getElementById("mask").style.display = "block"; | |||
| isValidate = true; | |||
| }, | |||
| spec_id: { | |||
| identifier: "spec_id", | |||
| rules: [{ type: "empty" }], | |||
| onFailure: function (e) { | |||
| isValidate = false; | |||
| return false; | |||
| }, | |||
| }, | |||
| onSuccess: function () { | |||
| // $('.ui.page.dimmer').dimmer('show') | |||
| document.getElementById("mask").style.display = "block"; | |||
| isValidate = true; | |||
| }, | |||
| onFailure: function (e) { | |||
| isValidate = false; | |||
| return false; | |||
| }, | |||
| }); | |||
| } | |||
| document.onreadystatechange = function () { | |||
| if (document.readyState === "complete") { | |||
| document.getElementById("mask").style.display = "none"; | |||
| }); | |||
| } | |||
| document.onreadystatechange = function () { | |||
| if (document.readyState === "complete") { | |||
| document.getElementById("mask").style.display = "none"; | |||
| } | |||
| }; | |||
| function send_run_para() { | |||
| var run_parameters = []; | |||
| var msg = {}; | |||
| $(".dynamic.field .two.fields").each(function () { | |||
| var para_name = $(this).find("input.shipping_first-name").val(); | |||
| var para_value = $(this).find("input.shipping_last-name").val(); | |||
| run_parameters.push({ label: para_name, value: para_value }); | |||
| }); | |||
| msg["parameter"] = run_parameters; | |||
| msg = JSON.stringify(msg); | |||
| $("#store_run_para").val(msg); | |||
| } | |||
| function get_name() { | |||
| let name1 = $("#engine_name .text").text(); | |||
| let name2 = $("#flaver_name .text").text(); | |||
| $("input#ai_engine_name").val(name1); | |||
| $("input#ai_flaver_name").val(name2); | |||
| } | |||
| }; | |||
| function send_run_para() { | |||
| var run_parameters = []; | |||
| var msg = {}; | |||
| $(".dynamic.field .two.fields").each(function () { | |||
| var para_name = $(this).find("input.shipping_first-name").val(); | |||
| var para_value = $(this).find("input.shipping_last-name").val(); | |||
| run_parameters.push({ label: para_name, value: para_value }); | |||
| }); | |||
| msg["parameter"] = run_parameters; | |||
| msg = JSON.stringify(msg); | |||
| $("#store_run_para").val(msg); | |||
| } | |||
| function get_name() { | |||
| let name1 = $("#engine_name .text").text(); | |||
| let name2 = $("#flaver_name .text").text(); | |||
| $("input#ai_engine_name").val(name1); | |||
| $("input#ai_flaver_name").val(name2); | |||
| } | |||
| validate(); | |||
| $(".ui.create_train_job.green.button").click(function (e) { | |||
| get_name(); | |||
| send_run_para(); | |||
| validate(); | |||
| }); | |||
| $(".ui.create_train_job.green.button").click(function (e) { | |||
| get_name(); | |||
| send_run_para(); | |||
| validate(); | |||
| }); | |||
| })(); | |||