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