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 21 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. {{template "base/head" .}}
  2. <style>
  3. .train-job-title {
  4. font-family: SourceHanSansSC-medium !important;
  5. color: rgba(16, 16, 16, 100) !important;
  6. font-size: 16px !important;
  7. padding-left: 3rem !important;
  8. }
  9. .min_title{
  10. font-size: 14px !important;
  11. margin-bottom: 2rem !important;
  12. }
  13. .width{
  14. width:100% !important;
  15. }
  16. .width80{
  17. width: 80.7% !important;
  18. margin-left: 10px;
  19. }
  20. .width806{
  21. width: 80.6% !important;
  22. margin-left: -2px;
  23. }
  24. .width85{
  25. width: 85% !important;
  26. margin-left: 10.5rem !important;
  27. align-items: center;
  28. }
  29. .width81{
  30. width: 81% !important;
  31. }
  32. .add{font-size: 18px;
  33. padding: 0.5rem;
  34. border: 1px solid rgba(187, 187, 187, 100);
  35. border-radius: 0px 5px 5px 0px;
  36. line-height: 21px;
  37. text-align: center;
  38. color: #C2C7CC;
  39. }
  40. .min{
  41. font-size: 18px;
  42. padding: 0.5rem;
  43. border: 1px solid rgba(187, 187, 187, 100);
  44. border-radius: 5px 0px 0px 5px;
  45. line-height: 21px;
  46. text-align: center;
  47. color: #C2C7CC;
  48. }
  49. .label-fix-width{
  50. width: 140px !important;
  51. text-align: right;
  52. font-family: SourceHanSansSC-medium !important;
  53. color: rgba(16, 16, 16, 100) !important;
  54. font-size: 14px !important;
  55. }
  56. </style>
  57. <!-- <div class="ui page dimmer">
  58. <div class="ui text loader">{{.i18n.Tr "loading"}}</div>
  59. </div> -->
  60. <div id="mask">
  61. <div id="loadingPage">
  62. <div class="rect1"></div>
  63. <div class="rect2"></div>
  64. <div class="rect3"></div>
  65. <div class="rect4"></div>
  66. <div class="rect5"></div>
  67. </div>
  68. </div>
  69. <div class="repository">
  70. {{template "repo/header" .}}
  71. <div class="ui container">
  72. {{template "base/alert" .}}
  73. <h4 class="ui top attached header">
  74. {{.i18n.Tr "repo.modelarts.train_job.new"}}
  75. </h4>
  76. <div class="ui attached segment">
  77. <!-- equal width -->
  78. <form class="ui form" action="{{.Link}}" method="post">
  79. {{.CsrfTokenHtml}}
  80. <input type="hidden" name="action" value="update">
  81. <input type="hidden" id="ai_engine_name" name="engine_names" value="">
  82. <input type="hidden" id="ai_flavor_name" name="flavor_name" value="">
  83. <h4 class="train-job-title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4>
  84. <div class="required min_title inline field">
  85. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.resource_cluster"}}</label>
  86. <div class="ui blue mini menu compact selectcloudbrain">
  87. <a class="item" href="{{.RepoLink}}/cloudbrain/train-job/create">
  88. <svg class="svg" sxmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-2.29-2.333A17.9 17.9 0 0 1 8.027 13H4.062a8.008 8.008 0 0 0 5.648 6.667zM10.03 13c.151 2.439.848 4.73 1.97 6.752A15.905 15.905 0 0 0 13.97 13h-3.94zm9.908 0h-3.965a17.9 17.9 0 0 1-1.683 6.667A8.008 8.008 0 0 0 19.938 13zM4.062 11h3.965A17.9 17.9 0 0 1 9.71 4.333 8.008 8.008 0 0 0 4.062 11zm5.969 0h3.938A15.905 15.905 0 0 0 12 4.248 15.905 15.905 0 0 0 10.03 11zm4.259-6.667A17.9 17.9 0 0 1 15.973 11h3.965a8.008 8.008 0 0 0-5.648-6.667z"></path></svg>
  89. {{.i18n.Tr "cloudbrain.resource_cluster_openi"}}
  90. </a>
  91. <a class="active item" href="{{.RepoLink}}/grampus/train-job/{{if.NPUEnabled}}npu{{else}}gpu{{end}}/create">
  92. <svg class="svg" sxmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-2.29-2.333A17.9 17.9 0 0 1 8.027 13H4.062a8.008 8.008 0 0 0 5.648 6.667zM10.03 13c.151 2.439.848 4.73 1.97 6.752A15.905 15.905 0 0 0 13.97 13h-3.94zm9.908 0h-3.965a17.9 17.9 0 0 1-1.683 6.667A8.008 8.008 0 0 0 19.938 13zM4.062 11h3.965A17.9 17.9 0 0 1 9.71 4.333 8.008 8.008 0 0 0 4.062 11zm5.969 0h3.938A15.905 15.905 0 0 0 12 4.248 15.905 15.905 0 0 0 10.03 11zm4.259-6.667A17.9 17.9 0 0 1 15.973 11h3.965a8.008 8.008 0 0 0-5.648-6.667z"></path></svg>
  93. {{.i18n.Tr "cloudbrain.resource_cluster_c2net"}}(Beta)
  94. </a>
  95. </div>
  96. </div>
  97. <div class="required min_title inline field">
  98. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.compute_resource"}}</label>
  99. <div class="ui blue mini menu compact selectcloudbrain">
  100. <a {{if.GPUEnabled}}class="active item" href="{{.RepoLink}}/grampus/train-job/gpu/create"{{else}}href="javascript:return false;" class="item disabled" {{end}}>
  101. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
  102. <path fill="none" d="M0 0h24v24H0z"/>
  103. <path 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"/>
  104. </svg>
  105. CPU/GPU
  106. </a>
  107. <a {{if.NPUEnabled}}class="item" href="{{.RepoLink}}/grampus/train-job/npu/create"{{else}}href="javascript:return false;" class="item disabled" {{end}} >
  108. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
  109. <path fill="none" d="M0 0h24v24H0z"/>
  110. <path 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"/>
  111. </svg>
  112. Ascend NPU</a>
  113. </div>
  114. </div>
  115. <div class="required min_title inline field">
  116. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.job_name"}}</label>
  117. <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}}" tabindex="3" onkeyup="this.value=this.value.replace(/[, ]/g,'')" autofocus required maxlength="64">
  118. <span class="tooltips" style="margin-left: 11.5rem;display: block;">{{.i18n.Tr "cloudbrain.job_name_rule"}}</span>
  119. </div>
  120. <div class="min_title inline field">
  121. <label class="label-fix-width" style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label>
  122. <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>
  123. </div>
  124. <div class="ui divider"></div>
  125. <h4 class="train-job-title ui header ">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:</h4>
  126. <div class="required min_title inline field">
  127. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.code_version"}}</label>
  128. <select class="ui dropdown width80 left2" id="code_version" name="branch_name">
  129. {{if .branch_name}}
  130. <option name="branch_name" value="{{.branch_name}}">{{.branch_name}}</option>
  131. {{range $k, $v :=.Branches}}
  132. {{ if ne $v $.branch_name }}
  133. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  134. {{end}}
  135. {{end}}
  136. {{else}}
  137. <option name="branch_name" value="{{.branchName}}">{{.branchName}}</option>
  138. {{range $k, $v :=.Branches}}
  139. {{ if ne $v $.branchName }}
  140. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  141. {{end}}
  142. {{end}}
  143. {{end}}
  144. </select>
  145. </div>
  146. <div id="images-new-grampus">
  147. </div>
  148. <div class="inline min_title field required">
  149. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label>
  150. {{if .bootFile}}
  151. <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="{{.bootFile}}" tabindex="3" autofocus required maxlength="255" >
  152. {{else}}
  153. <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255" >
  154. {{end}}
  155. <span>
  156. <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>
  157. </span>
  158. <a href="https://git.openi.org.cn/OpenIOSSG/MNIST_PytorchExample_GPU/src/branch/master/train_for_c2net.py" target="_blank">查看样例</a>
  159. </div>
  160. {{template "custom/select_dataset_train" .}}
  161. <span class="tooltips" style="margin-left: 11.5rem;margin-bottom: 2rem;">{{.i18n.Tr "repo.grampus.gpu_dataset_path_rule"}}</span>
  162. <div class="inline min_title field">
  163. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label>
  164. <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>
  165. <input id="store_run_para" type="hidden" name="run_para_list">
  166. <div class="dynamic field" style="margin-top: 1rem;">
  167. {{if .params}}
  168. {{if ne 0 (len .params)}}
  169. {{range $k ,$v := .params}}
  170. <div class="two fields width85" id="para{{$k}}">
  171. <div class="field">
  172. <input type="text" name="shipping_first-name" value={{$v.Label}} required>
  173. </div>
  174. <div class="field">
  175. <input type="text" name="shipping_last-name" value={{$v.Value}} required>
  176. </div>
  177. <span>
  178. <i class="trash icon"></i>
  179. </span>
  180. </div>
  181. {{end}}
  182. {{end}}
  183. {{end}}
  184. </div>
  185. </div>
  186. <div class="required min_title inline field" id="flavor_name">
  187. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label>
  188. <select class="ui dropdown width81" id="trainjob-flavor" style='width:385px' name="flavor">
  189. {{range .flavor_infos}}
  190. <option name="flavor" value="{{.ID}}">{{.Name}}</option>
  191. {{end}}
  192. </select>
  193. </div>
  194. <div class="inline min_title field">
  195. <label class="label-fix-width"></label>
  196. <button class="ui create_train_job green button">
  197. {{.i18n.Tr "repo.cloudbrain.new"}}
  198. </button>
  199. <a class="ui button" href="{{.RepoLink}}/modelarts/train-job">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  200. </div>
  201. <!-- 模态框 -->
  202. </form>
  203. </div>
  204. </div>
  205. </div>
  206. {{template "base/footer" .}}
  207. <script>
  208. //let url_href = window.location.pathname.split('create')[0]
  209. //$(".ui.button").attr('href',url_href)
  210. $('select.dropdown')
  211. .dropdown();
  212. $('.menu .item')
  213. .tab();
  214. let sever_num = $('#trainjob_work_server_num')
  215. $('.add').click(function(){
  216. sever_num.val(parseInt(sever_num.val())+1)
  217. if(sever_num.val()>=26){
  218. sever_num.val(parseInt(sever_num.val())-1)
  219. }
  220. })
  221. $('.min').click(function(){
  222. sever_num.val(parseInt(sever_num.val())-1)
  223. if(sever_num.val()<=0){
  224. sever_num.val(parseInt(sever_num.val())+1)
  225. }
  226. })
  227. // 参数增加、删除、修改、保存
  228. function Add_parameter(i){
  229. value = '<div class="two fields width85" id= "para'+ i +'">' +
  230. '<div class="field">' +
  231. '<input type="text" name="shipping_first-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}> ' +
  232. '</div> ' +
  233. '<div class="field"> ' +
  234. '<input type="text" name="shipping_last-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}>' +
  235. '</div>'+
  236. '<span>' +
  237. '<i class="trash icon">' +
  238. '</i>' +
  239. '</span>' +
  240. '</div>'
  241. $(".dynamic.field").append(value)
  242. }
  243. $('#add_run_para').click(function(){
  244. var len = $(".dynamic.field .two.fields").length
  245. Add_parameter(len)
  246. });
  247. $(".dynamic.field").on("click",".trash.icon", function() {
  248. var index = $(this).parent().parent().index()
  249. $(this).parent().parent().remove()
  250. var len = $(".dynamic.field .two.fields").length
  251. $(".dynamic.field .two.fields").each(function(){
  252. var cur_index = $(this).index()
  253. $(this).attr('id', 'para' + cur_index)
  254. })
  255. });
  256. $('.ui.parameter.green.button').click(function(){
  257. var parameters = [];
  258. $('table tr').each(function() {
  259. $(this).find('td:eq(1)').each(function(){
  260. parameters.push($(this).text());
  261. })
  262. $(this).find('input').each(function(){
  263. parameters.push($(this).text())
  264. })
  265. });
  266. $('.ui.parameter.modal')
  267. .modal('hide');
  268. for(var i = 2; i < parameters.length; i++){
  269. switch(i) {
  270. // 数据集uuid待完成
  271. // case (2):
  272. // console.log(1)
  273. // break;
  274. // $("#trainjob_datasets").val(parameters[i]);
  275. // console.log($("#trainjob_datasets").val())
  276. case (3):
  277. $("input[name='boot_file']").val(parameters[i]);
  278. break;
  279. case (4):
  280. var para = parameters[i].split(" ")
  281. for(var j = 0; j < para.length; j++){
  282. var para_name = para[j].split('=')[0]
  283. var para_value = para[j].split('=')[1]
  284. var len = $(".dynamic.field .two.fields").length
  285. Add_parameter(len)
  286. var pid = 'para' + len
  287. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_first-name]").val(para_name)
  288. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_last-name]").val(para_value)
  289. }
  290. break;
  291. // 数据集pool_id待完成
  292. // case (5):
  293. // $("select[name='pool_id']").val(parameters[i]);
  294. // break;
  295. case (6):
  296. $("input[name='work_server_number']").val(parameters[i]);
  297. break;
  298. }
  299. }
  300. })
  301. $('.ui.save.checkbox').click(function(){
  302. $(this).checkbox({
  303. onChange: function(){
  304. if ($('.ui.save.checkbox').checkbox('is checked')){
  305. $('#save_para').removeClass("disabled")
  306. }else{
  307. $('#save_para').addClass("disabled")
  308. }
  309. }
  310. });
  311. })
  312. $('.question.circle.icon').hover(function(){
  313. $(this).popup('show')
  314. });
  315. $(".item.active.parameter_config").click(function(){
  316. $('.ui.parameter.modal')
  317. .modal('setting', 'closable', false)
  318. .modal('show');
  319. })
  320. $('.ui.deny.button').click(function(){
  321. $('.ui.parameter.modal')
  322. .modal('hide');
  323. })
  324. $('select.dropdown')
  325. .dropdown();
  326. function validate(){
  327. $('.ui.form')
  328. .form({
  329. on: 'blur',
  330. fields: {
  331. boot_file: {
  332. identifier : 'boot_file',
  333. rules: [
  334. {
  335. type: 'regExp[/.+\.py$/g]',
  336. }
  337. ]
  338. },
  339. display_job_name:{
  340. identifier : 'display_job_name',
  341. rules: [
  342. {
  343. type: 'regExp[/^[a-zA-Z0-9-_]{1,64}[a-zA-Z0-9_]$/]',
  344. }
  345. ]
  346. },
  347. attachment:{
  348. identifier : 'attachment',
  349. rules: [
  350. {
  351. type: 'empty',
  352. }
  353. ]
  354. },
  355. flavor:{
  356. identifier : 'flavor',
  357. rules: [
  358. {
  359. type: 'empty',
  360. }
  361. ]
  362. },
  363. work_server_number: {
  364. identifier : 'work_server_number',
  365. rules: [
  366. {
  367. type : 'integer[1..25]',
  368. }
  369. ]
  370. }
  371. },
  372. onSuccess: function(){
  373. // $('.ui.page.dimmer').dimmer('show')
  374. document.getElementById("mask").style.display = "block"
  375. },
  376. onFailure: function(e){
  377. return false;
  378. }
  379. })
  380. }
  381. document.onreadystatechange = function() {
  382. if (document.readyState === "complete") {
  383. document.getElementById("mask").style.display = "none"
  384. }
  385. }
  386. function send_run_para(){
  387. var run_parameters = []
  388. var msg = {}
  389. $(".dynamic.field .two.fields").each(function(){
  390. var para_name = $(this).find('input[name=shipping_first-name]').val()
  391. var para_value = $(this).find('input[name=shipping_last-name]').val()
  392. run_parameters.push({"label": para_name, "value": para_value})
  393. })
  394. msg["parameter"] = run_parameters
  395. msg = JSON.stringify(msg)
  396. $('#store_run_para').val(msg)
  397. }
  398. function get_name(){
  399. let name1=$("#engine_name .text").text()
  400. let name2=$("#flavor_name .text").text()
  401. $("input#ai_engine_name").val(name1)
  402. $("input#ai_flavor_name").val(name2)
  403. }
  404. $('.ui.create_train_job.green.button').click(function(e) {
  405. get_name()
  406. send_run_para()
  407. validate()
  408. })
  409. </script>