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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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_flaver_name" name="flaver_names" 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.compute_resource"}}</label>
  82. <div class="ui blue mini menu compact selectcloudbrain">
  83. <a class="active item" href="{{.RepoLink}}/cloudbrain/train-job/create">
  84. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
  85. <path fill="none" d="M0 0h24v24H0z"/>
  86. <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"/>
  87. </svg>
  88. CPU/GPU
  89. </a>
  90. <a class="item" href="{{.RepoLink}}/modelarts/train-job/create">
  91. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
  92. <path fill="none" d="M0 0h24v24H0z"/>
  93. <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"/>
  94. </svg>
  95. Ascend NPU</a>
  96. </div>
  97. </div>
  98. <div class="required unite min_title inline field">
  99. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.job_name"}}</label>
  100. <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">
  101. <span class="tooltips" style="display: block;">{{.i18n.Tr "cloudbrain.job_name_rule"}}</span>
  102. </div>
  103. <div class="unite min_title inline field">
  104. <label style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}&nbsp;&nbsp;</label>
  105. <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>
  106. </div>
  107. <div class="ui divider"></div>
  108. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:</h4>
  109. <div class="required unite min_title inline field">
  110. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.code_version"}}</label>
  111. <select class="ui dropdown width80 left2" id="code_version" name="branch_name">
  112. {{if .branch_name}}
  113. <option name="branch_name" value="{{.branch_name}}">{{.branch_name}}</option>
  114. {{range $k, $v :=.Branches}}
  115. {{ if ne $v $.branch_name }}
  116. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  117. {{end}}
  118. {{end}}
  119. {{else}}
  120. <option name="branch_name" value="{{.branchName}}">{{.branchName}}</option>
  121. {{range $k, $v :=.Branches}}
  122. {{ if ne $v $.branchName }}
  123. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  124. {{end}}
  125. {{end}}
  126. {{end}}
  127. </select>
  128. </div>
  129. <div class="inline required field" style="display: none;">
  130. <label>{{.i18n.Tr "cloudbrain.task_type"}}</label>
  131. <select id="cloudbrain_job_type" class="ui search dropdown" placeholder="选择任务类型" style='width:385px' name="job_type">
  132. <option name="job_type" value="TRAIN">TRAIN</option>
  133. </select>
  134. </div>
  135. <div class="required unite min_title inline field">
  136. <label style="font-weight: normal;">{{.i18n.Tr "cloudbrain.gpu_type"}}</label>
  137. <select id="cloudbrain_gpu_type" class="ui search width806 dropdown" placeholder="选择GPU类型" style='width:385px' name="gpu_type">
  138. {{range .train_gpu_types}}
  139. <option value="{{.Queue}}">{{.Value}}</option>
  140. {{end}}
  141. </select>
  142. </div>
  143. <div class="required unite min_title inline field" style="position: relative;">
  144. <label style="font-weight: normal;">{{.i18n.Tr "cloudbrain.mirror"}}&nbsp;</label>
  145. <input class="width81" type="text" list="cloudbrain_image" placeholder="{{.i18n.Tr "cloudbrain.choose_mirror"}}" name="image" required autofocus maxlength="255">
  146. <i class="times circle outline icon icons" style="visibility: hidden;" onclick="clearValue()"></i>
  147. <datalist class="ui search" id="cloudbrain_image" name="image">
  148. {{range .images}}
  149. <option name="image" value="{{.Place}}">{{.PlaceView}}</option>
  150. {{end}}
  151. {{range .public_images}}
  152. <option name="image" value="{{.Place}}">{{.PlaceView}}</option>
  153. {{end}}
  154. </datalist>
  155. </div>
  156. <div class="inline unite min_title field required">
  157. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label>
  158. {{if .bootFile}}
  159. <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="{{.bootFile}}" tabindex="3" autofocus required maxlength="255" >
  160. {{else}}
  161. <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255" >
  162. {{end}}
  163. <span>
  164. <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>
  165. </span>
  166. <a href="https://git.openi.org.cn/OpenIOSSG/MNIST_PytorchExample_GPU" target="_blank">查看样例</a>
  167. </div>
  168. <div class="required unite min_title inline field" style="position: relative;">
  169. <label style="font-weight: normal;">{{.i18n.Tr "cloudbrain.dataset"}}</label>
  170. <select id="cloudbrain_dataset" class="ui search dropdown width80" placeholder="选择数据集" style='width:385px' name="attachment" required>
  171. {{range .attachments}}
  172. <option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option>
  173. {{end}}
  174. </select>
  175. <span class="tooltips">训练脚本存储在/code中,数据集存储在/dataset中,训练输出请存储在/model中以供后续下载。</span>
  176. </div>
  177. <div class="inline unite min_title field">
  178. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label>
  179. <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>
  180. <input id="store_run_para" type="hidden" name="run_para_list">
  181. <div class="dynamic field" style="margin-top: 1rem;">
  182. {{if .params}}
  183. {{if ne 0 (len .params)}}
  184. {{range $k ,$v := .params}}
  185. <div class="two fields width85" id="para{{$k}}">
  186. <div class="field">
  187. <input type="text" name="shipping_first-name" value={{$v.Label}} required>
  188. </div>
  189. <div class="field">
  190. <input type="text" name="shipping_last-name" value={{$v.Value}} required>
  191. </div>
  192. <span>
  193. <i class="trash icon"></i>
  194. </span>
  195. </div>
  196. {{end}}
  197. {{end}}
  198. {{end}}
  199. </div>
  200. </div>
  201. <div class="required inline unite min_title field">
  202. <label style="font-weight: normal;">{{.i18n.Tr "cloudbrain.resource_specification"}}</label>
  203. <select id="cloudbrain_resource_spec" class="ui search dropdown" placeholder="选择资源规格" style='width:385px' name="resource_spec_id">
  204. {{range .train_resource_specs}}
  205. <option name="resource_spec_id" value="{{.Id}}">GPU数:{{.GpuNum}},CPU数:{{.CpuNum}},内存(MB):{{.MemMiB}},共享内存(MB):{{.ShareMemMiB}}</option>
  206. {{end}}
  207. </select>
  208. </div>
  209. <div class="inline unite min_title field">
  210. <button class="ui create_train_job green button">
  211. {{.i18n.Tr "repo.cloudbrain.new"}}
  212. </button>
  213. <a class="ui button" href="{{.RepoLink}}/modelarts/train-job">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  214. </div>
  215. <!-- 模态框 -->
  216. </form>
  217. </div>
  218. </div>
  219. </div>
  220. {{template "base/footer" .}}
  221. <script>
  222. //let url_href = window.location.pathname.split('create')[0]
  223. //$(".ui.button").attr('href',url_href)
  224. $('select.dropdown')
  225. .dropdown();
  226. $('.menu .item')
  227. .tab();
  228. let sever_num = $('#trainjob_work_server_num')
  229. $('.add').click(function(){
  230. sever_num.val(parseInt(sever_num.val())+1)
  231. if(sever_num.val()>=26){
  232. sever_num.val(parseInt(sever_num.val())-1)
  233. }
  234. })
  235. $('.min').click(function(){
  236. sever_num.val(parseInt(sever_num.val())-1)
  237. if(sever_num.val()<=0){
  238. sever_num.val(parseInt(sever_num.val())+1)
  239. }
  240. })
  241. // 参数增加、删除、修改、保存
  242. function Add_parameter(i){
  243. value = '<div class="two fields width85" id= "para'+ i +'">' +
  244. '<div class="field">' +
  245. '<input type="text" name="shipping_first-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}> ' +
  246. '</div> ' +
  247. '<div class="field"> ' +
  248. '<input type="text" name="shipping_last-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}>' +
  249. '</div>'+
  250. '<span>' +
  251. '<i class="trash icon">' +
  252. '</i>' +
  253. '</span>' +
  254. '</div>'
  255. $(".dynamic.field").append(value)
  256. }
  257. $('#add_run_para').click(function(){
  258. var len = $(".dynamic.field .two.fields").length
  259. Add_parameter(len)
  260. });
  261. $(".dynamic.field").on("click",".trash.icon", function() {
  262. var index = $(this).parent().parent().index()
  263. $(this).parent().parent().remove()
  264. var len = $(".dynamic.field .two.fields").length
  265. $(".dynamic.field .two.fields").each(function(){
  266. var cur_index = $(this).index()
  267. $(this).attr('id', 'para' + cur_index)
  268. })
  269. });
  270. $('.ui.parameter.green.button').click(function(){
  271. var parameters = [];
  272. $('table tr').each(function() {
  273. $(this).find('td:eq(1)').each(function(){
  274. parameters.push($(this).text());
  275. })
  276. $(this).find('input').each(function(){
  277. parameters.push($(this).text())
  278. })
  279. });
  280. $('.ui.parameter.modal')
  281. .modal('hide');
  282. for(var i = 2; i < parameters.length; i++){
  283. switch(i) {
  284. // 数据集uuid待完成
  285. // case (2):
  286. // console.log(1)
  287. // break;
  288. // $("#trainjob_datasets").val(parameters[i]);
  289. // console.log($("#trainjob_datasets").val())
  290. case (3):
  291. $("input[name='boot_file']").val(parameters[i]);
  292. break;
  293. case (4):
  294. var para = parameters[i].split(" ")
  295. for(var j = 0; j < para.length; j++){
  296. var para_name = para[j].split('=')[0]
  297. var para_value = para[j].split('=')[1]
  298. var len = $(".dynamic.field .two.fields").length
  299. Add_parameter(len)
  300. var pid = 'para' + len
  301. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_first-name]").val(para_name)
  302. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_last-name]").val(para_value)
  303. }
  304. break;
  305. // 数据集pool_id待完成
  306. // case (5):
  307. // $("select[name='pool_id']").val(parameters[i]);
  308. // break;
  309. case (6):
  310. $("input[name='work_server_number']").val(parameters[i]);
  311. break;
  312. }
  313. }
  314. })
  315. $('.ui.save.checkbox').click(function(){
  316. $(this).checkbox({
  317. onChange: function(){
  318. if ($('.ui.save.checkbox').checkbox('is checked')){
  319. $('#save_para').removeClass("disabled")
  320. }else{
  321. $('#save_para').addClass("disabled")
  322. }
  323. }
  324. });
  325. })
  326. $('.question.circle.icon').hover(function(){
  327. $(this).popup('show')
  328. });
  329. $(".item.active.parameter_config").click(function(){
  330. $('.ui.parameter.modal')
  331. .modal('setting', 'closable', false)
  332. .modal('show');
  333. })
  334. $('.ui.deny.button').click(function(){
  335. $('.ui.parameter.modal')
  336. .modal('hide');
  337. })
  338. $('select.dropdown')
  339. .dropdown();
  340. function validate(){
  341. $('.ui.form')
  342. .form({
  343. on: 'blur',
  344. fields: {
  345. boot_file: {
  346. identifier : 'boot_file',
  347. rules: [
  348. {
  349. type: 'regExp[/.+\.py$/g]',
  350. }
  351. ]
  352. },
  353. display_job_name:{
  354. identifier : 'display_job_name',
  355. rules: [
  356. {
  357. type: 'regExp[/^[a-zA-Z0-9-_]{1,64}[a-zA-Z0-9_]$/]',
  358. }
  359. ]
  360. },
  361. attachment:{
  362. identifier : 'attachment',
  363. rules: [
  364. {
  365. type: 'empty',
  366. }
  367. ]
  368. },
  369. work_server_number: {
  370. identifier : 'work_server_number',
  371. rules: [
  372. {
  373. type : 'integer[1..25]',
  374. }
  375. ]
  376. }
  377. },
  378. onSuccess: function(){
  379. // $('.ui.page.dimmer').dimmer('show')
  380. document.getElementById("mask").style.display = "block"
  381. },
  382. onFailure: function(e){
  383. return false;
  384. }
  385. })
  386. }
  387. document.onreadystatechange = function() {
  388. if (document.readyState === "complete") {
  389. document.getElementById("mask").style.display = "none"
  390. }
  391. }
  392. function send_run_para(){
  393. var run_parameters = []
  394. var msg = {}
  395. $(".dynamic.field .two.fields").each(function(){
  396. var para_name = $(this).find('input[name=shipping_first-name]').val()
  397. var para_value = $(this).find('input[name=shipping_last-name]').val()
  398. run_parameters.push({"label": para_name, "value": para_value})
  399. })
  400. msg["parameter"] = run_parameters
  401. msg = JSON.stringify(msg)
  402. $('#store_run_para').val(msg)
  403. }
  404. function get_name(){
  405. let name1=$("#engine_name .text").text()
  406. let name2=$("#flaver_name .text").text()
  407. $("input#ai_engine_name").val(name1)
  408. $("input#ai_flaver_name").val(name2)
  409. }
  410. $('.ui.create_train_job.green.button').click(function(e) {
  411. get_name()
  412. send_run_para()
  413. validate()
  414. })
  415. </script>