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