You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

new.tmpl 26 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. {{template "base/head" .}}
  2. <style>
  3. .unite{
  4. font-family: SourceHanSansSC-medium !important;
  5. color: rgba(16, 16, 16, 100) !important;
  6. }
  7. .title{
  8. font-size: 16px !important;
  9. padding-left: 3rem !important;
  10. }
  11. .min_title{
  12. font-size: 14px !important;
  13. margin-bottom: 2rem !important;
  14. }
  15. .width80{
  16. width: 80.7% !important;
  17. }
  18. .width{
  19. width:100% !important;
  20. }
  21. .width85 {
  22. width: 85% !important;
  23. margin-left: 10.5rem !important;
  24. align-items: center;
  25. }
  26. .width35{
  27. width: 35.5% !important;
  28. }
  29. .width48{
  30. width: 48.5% !important;
  31. }
  32. .nowrapx {
  33. white-space: nowrap !important;
  34. }
  35. </style>
  36. <div id="mask">
  37. <div id="loadingPage">
  38. <div class="rect1"></div>
  39. <div class="rect2"></div>
  40. <div class="rect3"></div>
  41. <div class="rect4"></div>
  42. <div class="rect5"></div>
  43. </div>
  44. </div>
  45. <div class="repository">
  46. {{template "repo/header" .}}
  47. <div class="ui container">
  48. {{template "base/alert" .}}
  49. <h4 class="ui top attached header">
  50. {{.i18n.Tr "repo.modelarts.train_job.new_infer"}}
  51. </h4>
  52. <div class="ui attached segment">
  53. <!-- equal width -->
  54. <form class="ui form" action="{{.Link}}" method="post">
  55. {{.CsrfTokenHtml}}
  56. <input type="hidden" name="action" value="update">
  57. <input type="hidden" id="ai_engine_name" name="engine_names" value="">
  58. <input type="hidden" id="ai_flaver_name" name="flaver_names" value="">
  59. <input type="hidden" id="ai_model_version" name="model_version" value="">
  60. <input type="hidden" id="failed_train_url" value="{{$.train_url}}">
  61. <input type="hidden" id="failed_model_name" value="{{$.model_name}}">
  62. <input type="hidden" id="failed_model_version" value="{{$.model_version}}">
  63. <input type="hidden" id="failed_ckpt_name" value="{{$.ckpt_name}}">
  64. <input type="hidden" id="failed_train_url" value="{{$.train_url}}">
  65. <input type="hidden" id="fail_dataset_name" value="{{$.dataset_name}}">
  66. <input type="hidden" id="fail_dataset_uuid" value="{{$.attachment}}">
  67. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4>
  68. <div class="required min_title inline field">
  69. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.compute_resource"}}</label>
  70. <div class="ui blue mini menu compact selectcloudbrain">
  71. <a class="item" href="{{.RepoLink}}/cloudbrain/inference-job/create">
  72. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16"
  73. height="16">
  74. <path fill="none" d="M0 0h24v24H0z" />
  75. <path
  76. d="M3 2.992C3 2.444 3.445 2 3.993 2h16.014a1 1 0 0 1 .993.992v18.016a.993.993 0 0 1-.993.992H3.993A1 1 0 0 1 3 21.008V2.992zM19 11V4H5v7h14zm0 2H5v7h14v-7zM9 6h6v2H9V6zm0 9h6v2H9v-2z" />
  77. </svg>
  78. CPU/GPU
  79. </a>
  80. <a class="active item" href="{{.RepoLink}}/modelarts/inference-job/create">
  81. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16"
  82. height="16">
  83. <path fill="none" d="M0 0h24v24H0z" />
  84. <path
  85. d="M3 2.992C3 2.444 3.445 2 3.993 2h16.014a1 1 0 0 1 .993.992v18.016a.993.993 0 0 1-.993.992H3.993A1 1 0 0 1 3 21.008V2.992zM19 11V4H5v7h14zm0 2H5v7h14v-7zM9 6h6v2H9V6zm0 9h6v2H9v-2z" />
  86. </svg>
  87. Ascend NPU</a>
  88. </div>
  89. {{template "custom/wait_count_train" Dict "ctx" $}}
  90. </div>
  91. <div class="required min_title inline field">
  92. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.job_name"}}</label>
  93. <input style="width: 60%;" name="display_job_name" id="display_job_name" placeholder={{.i18n.Tr "repo.modelarts.train_job.job_name"}} value="{{.display_job_name}}" onkeyup="this.value=this.value.replace(/[, ]/g,'')" tabindex="3" autofocus required maxlength="36">
  94. <span class="tooltips" style="margin-left:11.5rem;display: block;">{{.i18n.Tr "repo.cloudbrain_jobname_err"}}</span>
  95. </div>
  96. <div class="min_title inline field">
  97. <label class="label-fix-width" style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label>
  98. {{if .description}}
  99. <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}}>{{.description}}</textarea>
  100. {{else}}
  101. <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, 255)"></textarea>
  102. {{end}}
  103. </div>
  104. <div class="ui divider"></div>
  105. <!-- 模型相关配置 -->
  106. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:</h4>
  107. <div class="required unite inline min_title fields" style="width: 96.8%;">
  108. <div class="required eight wide field">
  109. <label style="font-weight: normal;white-space: nowrap;width: 210px;text-align: right;">{{.i18n.Tr "repo.modelarts.infer_job.select_model"}}</label>
  110. <div class="ui fluid search selection dropdown loading " id="select_model">
  111. <input type="hidden" name="model_name" required>
  112. <div class="text"></div>
  113. <i class="dropdown icon"></i>
  114. <div class="menu" id="model_name">
  115. </div>
  116. </div>
  117. </div>
  118. <div class="three wide field">
  119. <div class="ui fluid search selection dropdown" id="select_model_version">
  120. <input type="hidden" name="train_url" required>
  121. <div class="text"></div>
  122. <i class="dropdown icon"></i>
  123. <div class="menu" id="model_name_version">
  124. </div>
  125. </div>
  126. </div>
  127. <div class="five wide field">
  128. <div class="ui fluid search selection dropdown" id="select_model_checkpoint">
  129. <input type="hidden" name="ckpt_name" required>
  130. <div class="text"></div>
  131. <i class="dropdown icon"></i>
  132. <div class="menu" id="model_checkpoint">
  133. </div>
  134. </div>
  135. </div>
  136. <span >
  137. <i class="question circle icon" data-content="{{.i18n.Tr "cloudbrain.model_file_path_rule"}}" data-position="top center" data-variation="inverted mini"></i>
  138. </span>
  139. </div>
  140. <!-- AI引擎 -->
  141. <div class="required inline min_title fields" style="width: 95%;">
  142. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.AI_driver"}}</label>
  143. <div class="field" style="flex: 1.5;">
  144. <select class="ui dropdown width" id="trainjob_engines">
  145. {{range .engines}}
  146. <option value="{{.Value}}">{{.Value}}</option>
  147. {{end}}
  148. </select>
  149. </div>
  150. <div class="field" style="flex: 2;" id="engine_name">
  151. <select class="ui dropdown width" id="trainjob_engine_versions" name="engine_id">
  152. {{if .engine_id}}
  153. {{range .engine_versions}}
  154. {{if eq $.engine_id .ID}}
  155. <option value="{{.ID}}">{{.Value}}</option>
  156. {{end}}
  157. {{end}}
  158. {{range .engine_versions}}
  159. {{if ne $.engine_id .ID}}
  160. <option value="{{.ID}}">{{.Value}}</option>
  161. {{end}}
  162. {{end}}
  163. {{else}}
  164. {{range .engine_versions}}
  165. <option value="{{.ID}}">{{.Value}}</option>
  166. {{end}}
  167. {{end}}
  168. </select>
  169. </div>
  170. </div>
  171. <!-- 代码分支 -->
  172. <div class="required min_title inline field">
  173. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.code_version"}}</label>
  174. <select class="ui dropdown width48" id="code_version" name="branch_name">
  175. {{if .branch_name}}
  176. <option name="branch_name" value="{{.branch_name}}">{{.branch_name}}</option>
  177. {{range $k, $v :=.Branches}}
  178. {{ if ne $v $.branch_name }}
  179. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  180. {{end}}
  181. {{end}}
  182. {{else}}
  183. <option name="branch_name" value="{{.branchName}}">{{.branchName}}</option>
  184. {{range $k, $v :=.Branches}}
  185. {{ if ne $v $.branchName }}
  186. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  187. {{end}}
  188. {{end}}
  189. {{end}}
  190. </select>
  191. </div>
  192. <!-- 数据集 -->
  193. {{template "custom/select_dataset_train" .}}
  194. <span class="tooltips" style="margin-left: 11.5rem;margin-bottom: 2rem;">{{.i18n.Tr "cloudbrain.dataset_path_rule"}}</span>
  195. <div class="inline min_title field required">
  196. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label>
  197. {{if .bootFile}}
  198. <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="{{.bootFile}}" tabindex="3" autofocus required maxlength="255" >
  199. {{else}}
  200. <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255" >
  201. {{end}}
  202. <span >
  203. <i class="question circle icon" data-content={{.i18n.Tr "repo.modelarts.infer_job.boot_file_helper"}} data-position="top center" data-variation="inverted mini"></i>
  204. </span>
  205. <a href="https://git.openi.org.cn/OpenIOSSG/MINIST_Example" target="_blank">{{.i18n.Tr "cloudbrain.view_sample"}}</a>
  206. </div>
  207. <!-- 运行参数 -->
  208. <div class="inline min_title field">
  209. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label>
  210. <span id="add_run_para" style="cursor:pointer;color: rgba(3, 102, 214, 100);font-size: 14px;line-height: 26px;font-family: SourceHanSansSC-medium;"><i class="plus square outline icon"></i>{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}}</span>
  211. <input id="store_run_para" type="hidden" name="run_para_list">
  212. <div class="dynamic field" style="margin-top: 1rem;">
  213. {{if ne 0 (len .params)}}
  214. {{range $k ,$v := .params}}
  215. <div class="two fields width85" id="para{{$k}}">
  216. <div class="field">
  217. <input type="text" name="shipping_first-name" value={{$v.Label}} required>
  218. </div>
  219. <div class="field">
  220. <input type="text" name="shipping_last-name" value={{$v.Value}} required>
  221. </div>
  222. <span>
  223. <i class="trash icon"></i>
  224. </span>
  225. </div>
  226. {{end}}
  227. {{end}}
  228. </div>
  229. </div>
  230. <div class="required field " style="display: none;">
  231. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.resource_pool"}}</label>
  232. <select class="ui dropdown" id="trainjob_resource_pool" style='width:385px' name="pool_id">
  233. {{range .resource_pools}}
  234. <option value="{{.ID}}">{{.Value}}</option>
  235. {{end}}
  236. </select>
  237. </div>
  238. <!-- 规格 -->
  239. <div class="required min_title inline field" id="flaver_name">
  240. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label>
  241. <select class="ui dropdown width80" id="trainjob-flavor" name="flavor">
  242. {{if .flavor}}
  243. {{range .flavor_infos}}
  244. {{if eq $.flavor .Code}}
  245. <option value="{{.Code}}">{{.Value}}</option>
  246. {{end}}
  247. {{end}}
  248. {{range .flavor_infos}}
  249. {{if ne $.flavor .Code}}
  250. <option value="{{.Code}}">{{.Value}}</option>
  251. {{end}}
  252. {{end}}
  253. {{else}}
  254. {{range .flavor_infos}}
  255. <option name="flavor" value="{{.Code}}">{{.Value}}</option>
  256. {{end}}
  257. {{end}}
  258. </select>
  259. </div>
  260. <!-- 计算节点 -->
  261. <div class="inline required min_title field">
  262. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.amount_of_compute_node"}}</label>
  263. <div class="ui labeled input" style="width: 5%;">
  264. <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>
  265. </div>
  266. <span class="tooltips" style="margin-left: 11.5rem;display: block;">{{.i18n.Tr "cloudbrain.inference_output_path_rule"}}</span>
  267. </div>
  268. <!-- 表单操作 -->
  269. <div class="inline min_title field">
  270. <label class="label-fix-width" style="font-weight: normal;"></label>
  271. <button class="ui create_train_job green button">
  272. {{.i18n.Tr "repo.cloudbrain.new"}}
  273. </button>
  274. <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  275. </div>
  276. <!-- 模态框 -->
  277. </form>
  278. </div>
  279. </div>
  280. </div>
  281. {{template "base/footer" .}}
  282. <script>
  283. const RepoLink = {{.RepoLink}}
  284. const url_href = window.location.pathname.split('create')[0]
  285. let nameMap,nameList
  286. $(".ui.button").attr('href',url_href)
  287. // 获取模型列表和模型名称对应的模型版本
  288. $(document).ready(function(){
  289. modelVersion()
  290. modelCkpt()
  291. $.get(`${RepoLink}/modelmanage/query_model_for_predict?type=1`, (data) => {
  292. nameMap = data.nameMap
  293. nameList = data.nameList
  294. let faildModelName = document.getElementById('failed_model_name').value
  295. let html = ''
  296. nameList.forEach(element => {
  297. html += `<div class="item" data-value=${element}>${element}</div>`
  298. });
  299. if(nameList.length!==0){
  300. $('#model_name').append(html)
  301. if(faildModelName){
  302. $("#select_model").dropdown('set text',faildModelName)
  303. $("#select_model").dropdown('set value',faildModelName)
  304. }else{
  305. $("#select_model").dropdown('set text',nameList[0])
  306. $("#select_model").dropdown('set value',nameList[0],nameList[0])
  307. }
  308. }
  309. $('#select_model').removeClass("loading")
  310. })
  311. })
  312. // 根据选中的模型名称获取相应的模型版本
  313. function modelVersion(){
  314. let faildModelVersion = $('#failed_model_version').val()
  315. let faildTrainUrl = $('#failed_train_url').val()
  316. $('#select_model').dropdown({
  317. onChange: function(value, text, $selectedItem) {
  318. $("#select_model_version").addClass("loading")
  319. $('#model_name_version').empty()
  320. let html = ''
  321. nameMap[value].forEach(element => {
  322. let {TrainTaskInfo} = element
  323. TrainTaskInfo = JSON.parse(TrainTaskInfo)
  324. html += `<div class="item" data-label="${element.Label}" data-id="${element.ID}" data-value="${element.Path}">${element.Version}</div>`
  325. });
  326. $('#model_name_version').append(html)
  327. $("#select_model_version").removeClass("loading")
  328. const initVersionText = $('#model_name_version div.item:first-child').text()
  329. const initVersionValue = $('#model_name_version div.item:first-child').data('value')
  330. if(faildModelVersion&&faildTrainUrl){
  331. $("#select_model_version").dropdown('set text',faildModelVersion)
  332. $("#select_model_version").dropdown('set value',faildTrainUrl,faildModelVersion,$('#model_name_version div.item:first-child'))
  333. }else{
  334. $("#select_model_version").dropdown('set text',initVersionText)
  335. $("#select_model_version").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child'))
  336. }
  337. }
  338. })
  339. }
  340. // 根据选中的模型版本获取相应的模型权重文件
  341. function modelCkpt(){
  342. let faildCkptName = $('#failed_ckpt_name').val()
  343. $('#select_model_version').dropdown({
  344. onChange: function(value, text, $selectedItem) {
  345. const dataID = $selectedItem[0].getAttribute("data-id")
  346. const label = $selectedItem[0].getAttribute("data-label")
  347. $("#select_model_checkpoint").addClass("loading")
  348. $("#model_checkpoint").empty()
  349. let html = ''
  350. loadCheckpointList(dataID).then((res)=>{
  351. res.forEach(element => {
  352. const ckptSuffix = element.FileName.split(".")
  353. const loadCheckpointFile = ['ckpt','pb','h5','json','pkl','pth','t7','pdparams','onnx','pbtxt','keras','mlmodel','cfg','pt']
  354. if(!element.IsDir && loadCheckpointFile.includes(ckptSuffix[ckptSuffix.length-1])){
  355. html += `<div class="item" data-value=${element.FileName}>${element.FileName}</div>`
  356. }
  357. })
  358. $('#model_checkpoint').append(html)
  359. $("#select_model_checkpoint").removeClass("loading")
  360. const initVersionText = $('#model_checkpoint div.item:first-child').text()
  361. const initVersionValue = $('#model_checkpoint div.item:first-child').data('value')
  362. if(faildCkptName){
  363. $("#select_model_checkpoint").dropdown('set text',faildCkptName)
  364. $("#select_model_checkpoint").dropdown('set value',faildCkptName,faildCkptName,$('#model_name_version div.item:first-child'))
  365. }else{
  366. $("#select_model_checkpoint").dropdown('set text',initVersionText)
  367. $("#select_model_checkpoint").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child'))
  368. }
  369. })
  370. $("input#ai_model_version").val(text)
  371. $("input#ai_model_label").val(label)
  372. }
  373. })
  374. }
  375. function loadCheckpointList(value){
  376. return new Promise((resolve,reject)=>{
  377. $.get(`${RepoLink}/modelmanage/query_modelfile_for_predict`,{ID:value}, (data) => {
  378. resolve(data)
  379. })
  380. })
  381. }
  382. $('.question.circle.icon').hover(function(){
  383. $(this).popup('show')
  384. });
  385. // 参数增加、删除、修改、保存
  386. function Add_parameter(i){
  387. value = '<div class="two fields width85" id= "para'+ i +'">' +
  388. '<div class="field">' +
  389. '<input type="text" name="shipping_first-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}> ' +
  390. '</div> ' +
  391. '<div class="field"> ' +
  392. '<input type="text" name="shipping_last-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}>' +
  393. '</div>'+
  394. '<span>' +
  395. '<i class="trash icon">' +
  396. '</i>' +
  397. '</span>' +
  398. '</div>'
  399. $(".dynamic.field").append(value)
  400. }
  401. $('#add_run_para').click(function(){
  402. var len = $(".dynamic.field .two.fields").length
  403. Add_parameter(len)
  404. });
  405. $(".dynamic.field").on("click",".trash.icon", function() {
  406. var index = $(this).parent().parent().index()
  407. $(this).parent().parent().remove()
  408. var len = $(".dynamic.field .two.fields").length
  409. $(".dynamic.field .two.fields").each(function(){
  410. var cur_index = $(this).index()
  411. $(this).attr('id', 'para' + cur_index)
  412. })
  413. });
  414. function send_run_para(){
  415. var run_parameters = []
  416. var msg = {}
  417. $(".dynamic.field .two.fields").each(function(){
  418. var para_name = $(this).find('input[name=shipping_first-name]').val()
  419. var para_value = $(this).find('input[name=shipping_last-name]').val()
  420. run_parameters.push({"label": para_name, "value": para_value})
  421. })
  422. msg["parameter"] = run_parameters
  423. msg = JSON.stringify(msg)
  424. $('#store_run_para').val(msg)
  425. }
  426. function get_name(){
  427. let name1=$("#engine_name .text").text()
  428. let name2=$("#flaver_name .text").text()
  429. $("input#ai_engine_name").val(name1)
  430. $("input#ai_flaver_name").val(name2)
  431. }
  432. function validate(){
  433. $('.ui.form')
  434. .form({
  435. on: 'blur',
  436. fields: {
  437. boot_file: {
  438. identifier : 'boot_file',
  439. rules: [
  440. {
  441. type: 'regExp[/.+\.py$/g]',
  442. }
  443. ]
  444. },
  445. display_job_name:{
  446. identifier : 'display_job_name',
  447. rules: [
  448. {
  449. type: 'regExp[/^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$/]',
  450. }
  451. ]
  452. },
  453. attachment:{
  454. identifier : 'attachment',
  455. rules: [
  456. {
  457. type: 'empty',
  458. }
  459. ]
  460. },
  461. model_name:{
  462. identifier : 'model_name',
  463. rules: [
  464. {
  465. type: 'empty',
  466. }
  467. ]
  468. },
  469. train_url:{
  470. identifier : 'train_url',
  471. rules: [
  472. {
  473. type: 'empty',
  474. }
  475. ]
  476. },
  477. ckpt_name:{
  478. identifier : 'ckpt_name',
  479. rules: [
  480. {
  481. type: 'empty',
  482. }
  483. ]
  484. }
  485. },
  486. onSuccess: function(){
  487. document.getElementById("mask").style.display = "block"
  488. },
  489. onFailure: function(e){
  490. return false;
  491. }
  492. })
  493. }
  494. document.onreadystatechange = function() {
  495. if (document.readyState === "complete") {
  496. document.getElementById("mask").style.display = "none"
  497. }
  498. }
  499. validate();
  500. $('.ui.create_train_job.green.button').click(function(e) {
  501. send_run_para()
  502. get_name()
  503. })
  504. </script>