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.

version_new.tmpl 23 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
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
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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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. padding-left: 6rem !important;
  14. margin-bottom: 2rem !important;
  15. }
  16. .width{
  17. width:100% !important;
  18. }
  19. .width80{
  20. width: 80.7% !important;
  21. margin-left: 10px;
  22. }
  23. .width85{
  24. width: 85% !important;
  25. margin-left: 4.5rem !important;
  26. }
  27. .width81{
  28. margin-left: 1.5rem;
  29. width: 81% !important;
  30. }
  31. .add{font-size: 18px;
  32. padding: 0.5rem;
  33. border: 1px solid rgba(187, 187, 187, 100);
  34. border-radius: 0px 5px 5px 0px;
  35. line-height: 21px;
  36. text-align: center;
  37. color: #C2C7CC;
  38. }
  39. .min{
  40. font-size: 18px;
  41. padding: 0.5rem;
  42. border: 1px solid rgba(187, 187, 187, 100);
  43. border-radius: 5px 0px 0px 5px;
  44. line-height: 21px;
  45. text-align: center;
  46. color: #C2C7CC;"
  47. }
  48. </style>
  49. <!-- <div class="ui page dimmer">
  50. <div class="ui text loader">{{.i18n.Tr "loading"}}</div>
  51. </div> -->
  52. <div id="mask">
  53. <div id="loadingPage">
  54. <div class="rect1"></div>
  55. <div class="rect2"></div>
  56. <div class="rect3"></div>
  57. <div class="rect4"></div>
  58. <div class="rect5"></div>
  59. </div>
  60. </div>
  61. <div class="repository">
  62. {{template "repo/header" .}}
  63. <div class="ui container">
  64. {{template "base/alert" .}}
  65. <h4 class="ui top attached header">
  66. {{.i18n.Tr "repo.modelarts.train_job.new"}}
  67. </h4>
  68. <div class="ui attached segment">
  69. <!-- equal width -->
  70. <form class="ui form" action="{{$.RepoLink}}/modelarts/train-job/{{.JobID}}/create_version" method="post">
  71. {{.CsrfTokenHtml}}
  72. <input type="hidden" name="action" value="update">
  73. {{if .version_name}}
  74. <input type="hidden" name="version_name" value="{{.version_name}}">
  75. {{else}}
  76. <input type="hidden" name="version_name" value="">
  77. {{end}}
  78. <input type="hidden" id="ai_engine_name" name="engine_names" value="">
  79. <input type="hidden" id="ai_flaver_name" name="flaver_names" value="">
  80. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4>
  81. <div class="required unite min_title inline field">
  82. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.job_name"}}</label>
  83. <input type="hidden" style="width: 60%;" name="job_name" id="trainjob_job_name" value="{{.job_name}}">
  84. <input style="width: 60%;" value="{{.job_name}}" tabindex="3" disabled >
  85. </div>
  86. <div class="required unite min_title inline field">
  87. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.parents_version"}}</label>
  88. {{if .version_name}}
  89. <input style="width: 60%;" value="{{.version_name}}" tabindex="3" disabled >
  90. {{else}}
  91. <input id="parents_version" style="width: 60%;" value="" tabindex="3" disabled >
  92. {{end}}
  93. </div>
  94. <div class="unite min_title inline field">
  95. <label style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}&nbsp;&nbsp;</label>
  96. <textarea style="width: 80%;" id="description" value="{{.description}}" name="description" rows="3" maxlength="254" 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)">{{.description}}</textarea>
  97. </div>
  98. <div class="ui divider"></div>
  99. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:</h4>
  100. <div class="required unite min_title inline field">
  101. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.code_version"}}</label>
  102. <select class="ui dropdown width80 left2" id="code_version" name="branch_name">
  103. {{if .branch_name}}
  104. <option name="branch_name" value="{{.branch_name}}">{{.branch_name}}</option>
  105. {{end}}
  106. {{range $k, $v :=.branches}}
  107. {{if ne $.branch_name $v}}
  108. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  109. {{end}}
  110. {{end}}
  111. </select>
  112. </div>
  113. <div class="required unite min_title inline fields" style="width: 90%;">
  114. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.AI_driver"}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
  115. <div class="field" style="flex: 1.5;">
  116. <select class="ui dropdown width" id="trainjob_engines" >
  117. {{range .engines}}
  118. <option value="{{.Value}}">{{.Value}}</option>
  119. {{end}}
  120. </select>
  121. </div>
  122. <div class="field" style="flex: 2;" id="engine_name">
  123. <select class="ui dropdown width" id="trainjob_engine_versions" style='width: 100%;' name="engine_id">
  124. {{if .engine_id}}
  125. <option name="engine_id" value="{{.engine_id}}">{{.engine_name}}</option>
  126. {{end}}
  127. {{range .engine_versions}}
  128. {{if ne $.engine_id .ID}}
  129. <option name="engine_id" value="{{.ID}}">{{.Value}}</option>
  130. {{end}}
  131. {{end}}
  132. </select>
  133. </div>
  134. </div>
  135. <div class="inline unite min_title field required">
  136. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label>
  137. {{if .boot_file}}
  138. <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="{{.boot_file}}" tabindex="3" autofocus required maxlength="254" >
  139. {{else}}
  140. <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="254" >
  141. {{end}}
  142. <span>
  143. <i class="question circle icon link" data-content={{.i18n.Tr "repo.modelarts.train_job.boot_file_helper"}} data-position="right center" data-variation="mini"></i>
  144. </span>
  145. </div>
  146. <div class="required unite min_title inline field">
  147. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.dataset"}}</label>
  148. <select class="ui dropdown width80" id="trainjob_datasets" name="attachment" placeholder="选择数据集">
  149. {{if .dataset_name}}
  150. <option name="attachment" value="{{.uuid}}">{{.dataset_name}}</option>
  151. {{end}}
  152. {{range .attachments}}
  153. <option value="">选择数据集</option>
  154. {{if ne $.uuid .UUID}}
  155. <option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option>
  156. {{end}}
  157. {{end}}
  158. </select>
  159. </div>
  160. <div class="inline unite min_title field">
  161. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label>
  162. <span id="add_run_para" style="margin-left: 0.5rem;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>
  163. <input id="store_run_para" type="hidden" name="run_para_list">
  164. <div class="dynamic field" style="margin-top: 1rem;">
  165. {{if ne 0 (len .params)}}
  166. {{range $k ,$v := .params}}
  167. <div class="two fields width85" id="para{{$k}}">
  168. <div class="field">
  169. <input type="text" name="shipping_first-name" value={{$v.Label}} required>
  170. </div>
  171. <div class="field">
  172. <input type="text" name="shipping_last-name" value={{$v.Value}} required>
  173. </div>
  174. <span>
  175. <i class="trash icon"></i>
  176. </span>
  177. </div>
  178. {{end}}
  179. {{end}}
  180. </div>
  181. </div>
  182. <div class="required field " style="display: none;">
  183. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.resource_pool"}}</label>
  184. <select class="ui dropdown" id="trainjob_resource_pool" style='width:385px' name="pool_id">
  185. {{range .resource_pools}}
  186. <option value="{{.ID}}">{{.Value}}</option>
  187. {{end}}
  188. </select>
  189. </div>
  190. <div class="required grouped fields" style="display: none;">
  191. <label style="font-weight: normal;" for="resource_type">{{.i18n.Tr "repo.modelarts.train_job.resource_type"}}</label>
  192. <div class="field">
  193. <div class="ui grid">
  194. <div class="column">
  195. <div class="ui radio checkbox">
  196. <input type="radio" name="resource_type" checked="" tabindex="0">
  197. </div>
  198. </div>
  199. <div class="three wide column">train-private-1</div>
  200. <div class="three wide column">{{svg "octicon-verified" 16}} 运行中</div>
  201. <div class="three wide column"> CPU:192 核 2048GiB</div>
  202. </div>
  203. </div>
  204. </div>
  205. <div class="required unite min_title inline field" id="flaver_name">
  206. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label>
  207. <select class="ui dropdown width81" id="trainjob-flavor" style='width:385px' name="flavor">
  208. {{if .flavor_name}}
  209. <option name="flavor" value="{{.flavor_code}}">{{.flavor_name}}</option>
  210. {{end}}
  211. {{range .flavor_infos}}
  212. {{if ne $.flavor_code .Code}}
  213. <option name="flavor" value="{{.Code}}">{{.Value}}</option>
  214. {{end}}
  215. {{end}}
  216. </select>
  217. </div>
  218. <div class="inline required unite min_title field">
  219. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.amount_of_compute_node"}}</label>
  220. <div class="ui labeled input" style="width: 5%;">
  221. <input style="border-radius: 0;text-align: center;" name="work_server_number" id="trainjob_work_server_num" tabindex="3" autofocus required maxlength="254" value="{{.work_server_number}}" readonly>
  222. </div>
  223. </div>
  224. <div class="inline unite min_title field">
  225. <button class="ui create_train_job green button">
  226. {{.i18n.Tr "repo.cloudbrain.new"}}
  227. </button>
  228. <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  229. </div>
  230. <!-- 模态框 -->
  231. </form>
  232. </div>
  233. </div>
  234. </div>
  235. {{template "base/footer" .}}
  236. <script>
  237. let url_href = location.pathname.split('create_version')[0]
  238. let url_post = location.pathname
  239. let version_name = location.search.split('?version_name=')[1]
  240. $("#parents_version").val(version_name)
  241. $(".ui.button").attr('href',url_href)
  242. $(".ui.form").attr('action',url_post)
  243. $("input[name=version_name]").attr('value',version_name)
  244. $('select.dropdown')
  245. .dropdown();
  246. $('.menu .item')
  247. .tab();
  248. let sever_num = $('#trainjob_work_server_num')
  249. $('.add').click(function(){
  250. sever_num.val(parseInt(sever_num.val())+1)
  251. if(sever_num.val()>=26){
  252. sever_num.val(parseInt(sever_num.val())-1)
  253. }
  254. })
  255. $('.min').click(function(){
  256. sever_num.val(parseInt(sever_num.val())-1)
  257. if(sever_num.val()<=0){
  258. sever_num.val(parseInt(sever_num.val())+1)
  259. }
  260. })
  261. // 参数增加、删除、修改、保存
  262. function Add_parameter(i){
  263. value = '<div class="two fields width85" id= "para'+ i +'">' +
  264. '<div class="field">' +
  265. '<input type="text" name="shipping_first-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}> ' +
  266. '</div> ' +
  267. '<div class="field"> ' +
  268. '<input type="text" name="shipping_last-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}>' +
  269. '</div>'+
  270. '<span>' +
  271. '<i class="trash icon">' +
  272. '</i>' +
  273. '</span>' +
  274. '</div>'
  275. $(".dynamic.field").append(value)
  276. }
  277. $('#add_run_para').click(function(){
  278. var len = $(".dynamic.field .two.fields").length
  279. Add_parameter(len)
  280. });
  281. $(".dynamic.field").on("click",".trash.icon", function() {
  282. var index = $(this).parent().parent().index()
  283. $(this).parent().parent().remove()
  284. var len = $(".dynamic.field .two.fields").length
  285. $(".dynamic.field .two.fields").each(function(){
  286. var cur_index = $(this).index()
  287. $(this).attr('id', 'para' + cur_index)
  288. })
  289. });
  290. $('.ui.parameter.green.button').click(function(){
  291. var parameters = [];
  292. $('table tr').each(function() {
  293. $(this).find('td:eq(1)').each(function(){
  294. parameters.push($(this).text());
  295. })
  296. $(this).find('input').each(function(){
  297. parameters.push($(this).text())
  298. })
  299. });
  300. $('.ui.parameter.modal')
  301. .modal('hide');
  302. for(var i = 2; i < parameters.length; i++){
  303. switch(i) {
  304. // 数据集uuid待完成
  305. // case (2):
  306. // console.log(1)
  307. // break;
  308. // $("#trainjob_datasets").val(parameters[i]);
  309. // console.log($("#trainjob_datasets").val())
  310. case (3):
  311. $("input[name='boot_file']").val(parameters[i]);
  312. break;
  313. case (4):
  314. var para = parameters[i].split(" ")
  315. for(var j = 0; j < para.length; j++){
  316. var para_name = para[j].split('=')[0]
  317. var para_value = para[j].split('=')[1]
  318. var len = $(".dynamic.field .two.fields").length
  319. Add_parameter(len)
  320. var pid = 'para' + len
  321. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_first-name]").val(para_name)
  322. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_last-name]").val(para_value)
  323. }
  324. break;
  325. // 数据集pool_id待完成
  326. // case (5):
  327. // $("select[name='pool_id']").val(parameters[i]);
  328. // break;
  329. case (6):
  330. $("input[name='work_server_number']").val(parameters[i]);
  331. break;
  332. }
  333. }
  334. })
  335. $('.ui.save.checkbox').click(function(){
  336. $(this).checkbox({
  337. onChange: function(){
  338. if ($('.ui.save.checkbox').checkbox('is checked')){
  339. $('#save_para').removeClass("disabled")
  340. }else{
  341. $('#save_para').addClass("disabled")
  342. }
  343. }
  344. });
  345. })
  346. $('.question.circle.icon').hover(function(){
  347. $(this).popup('show')
  348. });
  349. $(".item.active.parameter_config").click(function(){
  350. $('.ui.parameter.modal')
  351. .modal('setting', 'closable', false)
  352. .modal('show');
  353. })
  354. $('.ui.deny.button').click(function(){
  355. $('.ui.parameter.modal')
  356. .modal('hide');
  357. })
  358. $('select.dropdown')
  359. .dropdown();
  360. $('.ui.form')
  361. .form({
  362. on: 'blur',
  363. inline:true,
  364. fields: {
  365. boot_file: {
  366. identifier : 'boot_file',
  367. rules: [
  368. {
  369. type: 'regExp[/.+\.py$/g]',
  370. prompt : '启动文件必须为.py结尾'
  371. }
  372. ]
  373. },
  374. job_name:{
  375. identifier : 'job_name',
  376. rules: [
  377. {
  378. type: 'regExp[/^[a-zA-Z0-9-_]{1,36}$/]',
  379. prompt : '只包含大小写字母、数字、_和-,最长36个字符。'
  380. }
  381. ]
  382. },
  383. attachment:{
  384. identifier : 'attachment',
  385. rules: [
  386. {
  387. type: 'empty',
  388. prompt : '选择一个数据集'
  389. }
  390. ]
  391. },
  392. work_server_number: {
  393. identifier : 'work_server_number',
  394. rules: [
  395. {
  396. type : 'integer[1..25]',
  397. prompt : '计算节点需要在1-25之间,请您键入正确的值'
  398. }
  399. ]
  400. },
  401. run_para_list:{
  402. identifier : 'run_para_list',
  403. rules: [
  404. {
  405. type: 'maxLength[255]',
  406. prompt : '所有字符最长不超过255个字符。'
  407. }
  408. ]
  409. },
  410. },
  411. })
  412. function validate(){
  413. $('.ui.form')
  414. .form({
  415. on: 'blur',
  416. inline:true,
  417. fields: {
  418. boot_file: {
  419. identifier : 'boot_file',
  420. rules: [
  421. {
  422. type: 'regExp[/.+\.py$/g]',
  423. prompt : '启动文件必须为.py结尾'
  424. }
  425. ]
  426. },
  427. job_name:{
  428. identifier : 'job_name',
  429. rules: [
  430. {
  431. type: 'regExp[/^[a-zA-Z0-9-_]{1,36}$/]',
  432. prompt : '只包含大小写字母、数字、_和-,最长36个字符。'
  433. }
  434. ]
  435. },
  436. attachment:{
  437. identifier : 'attachment',
  438. rules: [
  439. {
  440. type: 'empty',
  441. prompt : '选择一个数据集'
  442. }
  443. ]
  444. },
  445. work_server_number: {
  446. identifier : 'work_server_number',
  447. rules: [
  448. {
  449. type : 'integer[1..25]',
  450. prompt : '计算节点需要在1-25之间,请您键入正确的值'
  451. }
  452. ]
  453. },
  454. run_para_list:{
  455. identifier : 'run_para_list',
  456. rules: [
  457. {
  458. type: 'maxLength[255]',
  459. prompt : '所有字符最长不超过255个字符。'
  460. }
  461. ]
  462. },
  463. },
  464. onSuccess: function(){
  465. // $('.ui.page.dimmer').dimmer('show')
  466. document.getElementById("mask").style.display = "block"
  467. },
  468. onFailure: function(e){
  469. return false;
  470. }
  471. })
  472. }
  473. document.onreadystatechange = function() {
  474. if (document.readyState === "complete") {
  475. document.getElementById("mask").style.display = "none"
  476. }
  477. }
  478. function send_run_para(){
  479. var run_parameters = []
  480. var msg = {}
  481. $(".dynamic.field .two.fields").each(function(){
  482. var para_name = $(this).find('input[name=shipping_first-name]').val()
  483. var para_value = $(this).find('input[name=shipping_last-name]').val()
  484. run_parameters.push({"label": para_name, "value": para_value})
  485. })
  486. msg["parameter"] = run_parameters
  487. msg = JSON.stringify(msg)
  488. $('#store_run_para').val(msg)
  489. }
  490. function get_name(){
  491. let name1=$("#engine_name .text").text()
  492. let name2=$("#flaver_name .text").text()
  493. $("input#ai_engine_name").val(name1)
  494. $("input#ai_flaver_name").val(name2)
  495. }
  496. $('.ui.create_train_job.green.button').click(function(e) {
  497. get_name()
  498. send_run_para()
  499. validate()
  500. })
  501. </script>