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