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