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
4 years ago
3 years ago
4 years ago
4 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
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 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
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 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
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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_names" value="">
  74. <input type="hidden" id="ai_flaver_name" name="flaver_names" 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 "repo.modelarts.train_job.job_name"}}</label>
  78. <input style="width: 60%;" name="job_name" id="trainjob_job_name" placeholder={{.i18n.Tr "repo.modelarts.train_job.job_name"}} value="{{.job_name}}" tabindex="3" autofocus required maxlength="254">
  79. </div>
  80. <div class="unite min_title inline field">
  81. <label style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}&nbsp;&nbsp;</label>
  82. <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="254" 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>
  83. </div>
  84. <div class="ui divider"></div>
  85. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:</h4>
  86. <div class="required unite min_title inline field">
  87. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.code_version"}}</label>
  88. <select class="ui dropdown width80 left2" id="code_version" name="branch_name">
  89. {{if .branch_name}}
  90. <option name="branch_name" value="{{.branch_name}}">{{.branch_name}}</option>
  91. {{range $k, $v :=.Branches}}
  92. {{ if ne $v $.branch_name }}
  93. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  94. {{end}}
  95. {{end}}
  96. {{else}}
  97. <option name="branch_name" value="{{.branchName}}">{{.branchName}}</option>
  98. {{range $k, $v :=.Branches}}
  99. {{ if ne $v $.branchName }}
  100. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  101. {{end}}
  102. {{end}}
  103. {{end}}
  104. </select>
  105. </div>
  106. <div class="required unite min_title inline fields" style="width: 90%;">
  107. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.AI_driver"}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
  108. <div class="field" style="flex: 1.5;">
  109. <select class="ui dropdown width" id="trainjob_engines" >
  110. {{range .engines}}
  111. <option value="{{.Value}}">{{.Value}}</option>
  112. {{end}}
  113. </select>
  114. </div>
  115. <div class="field" style="flex: 2;" id="engine_name">
  116. <select class="ui dropdown width" id="trainjob_engine_versions" style='width: 100%;' name="engine_id">
  117. {{range .engine_versions}}
  118. <option name="engine_id" value="{{.ID}}">{{.Value}}</option>
  119. {{end}}
  120. </select>
  121. </div>
  122. </div>
  123. <div class="inline unite min_title field required">
  124. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label>
  125. {{if .bootFile}}
  126. <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="{{.bootFile}}" tabindex="3" autofocus required maxlength="254" >
  127. {{else}}
  128. <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="254" >
  129. {{end}}
  130. <span>
  131. <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>
  132. </span>
  133. <a href="https://git.openi.org.cn/OpenIOSSG/MINIST_Example" target="_blank">查看样例</a>
  134. </div>
  135. <div class="required unite min_title inline field">
  136. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.dataset"}}</label>
  137. <select class="ui dropdown width80" id="trainjob_datasets" name="attachment" placeholder="选择数据集">
  138. {{if $.uuid}}
  139. <option name="attachment" value="{{$.uuid}}">{{$.datasetName}}</option>
  140. {{end}}
  141. {{range .attachments}}
  142. <option value="">选择数据集</option>
  143. <option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option>
  144. {{end}}
  145. </select>
  146. <span class="tooltips">数据集位置存储在环境变量data_url中,训练输出路径存储在环境变量train_url中。</span>
  147. </div>
  148. <div class="inline unite min_title field">
  149. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label>
  150. <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>
  151. <input id="store_run_para" type="hidden" name="run_para_list">
  152. <div class="dynamic field" style="margin-top: 1rem;">
  153. {{if ne 0 (len .params)}}
  154. {{range $k ,$v := .params}}
  155. <div class="two fields width85" id="para{{$k}}">
  156. <div class="field">
  157. <input type="text" name="shipping_first-name" value={{$v.Label}} required>
  158. </div>
  159. <div class="field">
  160. <input type="text" name="shipping_last-name" value={{$v.Value}} required>
  161. </div>
  162. <span>
  163. <i class="trash icon"></i>
  164. </span>
  165. </div>
  166. {{end}}
  167. {{end}}
  168. </div>
  169. </div>
  170. <div class="required field " style="display: none;">
  171. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.resource_pool"}}</label>
  172. <select class="ui dropdown" id="trainjob_resource_pool" style='width:385px' name="pool_id">
  173. {{range .resource_pools}}
  174. <option value="{{.ID}}">{{.Value}}</option>
  175. {{end}}
  176. </select>
  177. </div>
  178. <div class="required grouped fields" style="display: none;">
  179. <label style="font-weight: normal;" for="resource_type">{{.i18n.Tr "repo.modelarts.train_job.resource_type"}}</label>
  180. <div class="field">
  181. <div class="ui grid">
  182. <div class="column">
  183. <div class="ui radio checkbox">
  184. <input type="radio" name="resource_type" checked="" tabindex="0">
  185. </div>
  186. </div>
  187. <div class="three wide column">train-private-1</div>
  188. <div class="three wide column">{{svg "octicon-verified" 16}} 运行中</div>
  189. <div class="three wide column"> CPU:192 核 2048GiB</div>
  190. </div>
  191. </div>
  192. </div>
  193. <div class="required unite min_title inline field" id="flaver_name">
  194. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label>
  195. <select class="ui dropdown width81" id="trainjob-flavor" style='width:385px' name="flavor">
  196. {{range .flavor_infos}}
  197. <option name="flavor" value="{{.Code}}">{{.Value}}</option>
  198. {{end}}
  199. </select>
  200. </div>
  201. <div class="inline required unite min_title field">
  202. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.amount_of_compute_node"}}</label>
  203. <div class="ui labeled input" style="width: 5%;">
  204. <input style="border-radius: 0;text-align: center;" name="work_server_number" id="trainjob_work_server_num" tabindex="3" autofocus required maxlength="254" value="1" readonly>
  205. </div>
  206. </div>
  207. <div class="inline unite min_title field">
  208. <button class="ui create_train_job green button">
  209. {{.i18n.Tr "repo.cloudbrain.new"}}
  210. </button>
  211. <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  212. </div>
  213. <!-- 模态框 -->
  214. </form>
  215. </div>
  216. </div>
  217. </div>
  218. {{template "base/footer" .}}
  219. <script>
  220. let url_href = window.location.pathname.split('create')[0]
  221. $(".ui.button").attr('href',url_href)
  222. $('select.dropdown')
  223. .dropdown();
  224. $('.menu .item')
  225. .tab();
  226. let sever_num = $('#trainjob_work_server_num')
  227. $('.add').click(function(){
  228. sever_num.val(parseInt(sever_num.val())+1)
  229. if(sever_num.val()>=26){
  230. sever_num.val(parseInt(sever_num.val())-1)
  231. }
  232. })
  233. $('.min').click(function(){
  234. sever_num.val(parseInt(sever_num.val())-1)
  235. if(sever_num.val()<=0){
  236. sever_num.val(parseInt(sever_num.val())+1)
  237. }
  238. })
  239. // 参数增加、删除、修改、保存
  240. function Add_parameter(i){
  241. value = '<div class="two fields width85" id= "para'+ i +'">' +
  242. '<div class="field">' +
  243. '<input type="text" name="shipping_first-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}> ' +
  244. '</div> ' +
  245. '<div class="field"> ' +
  246. '<input type="text" name="shipping_last-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}>' +
  247. '</div>'+
  248. '<span>' +
  249. '<i class="trash icon">' +
  250. '</i>' +
  251. '</span>' +
  252. '</div>'
  253. $(".dynamic.field").append(value)
  254. }
  255. $('#add_run_para').click(function(){
  256. var len = $(".dynamic.field .two.fields").length
  257. Add_parameter(len)
  258. });
  259. $(".dynamic.field").on("click",".trash.icon", function() {
  260. var index = $(this).parent().parent().index()
  261. $(this).parent().parent().remove()
  262. var len = $(".dynamic.field .two.fields").length
  263. $(".dynamic.field .two.fields").each(function(){
  264. var cur_index = $(this).index()
  265. $(this).attr('id', 'para' + cur_index)
  266. })
  267. });
  268. $('.ui.parameter.green.button').click(function(){
  269. var parameters = [];
  270. $('table tr').each(function() {
  271. $(this).find('td:eq(1)').each(function(){
  272. parameters.push($(this).text());
  273. })
  274. $(this).find('input').each(function(){
  275. parameters.push($(this).text())
  276. })
  277. });
  278. console.log(parameters)
  279. $('.ui.parameter.modal')
  280. .modal('hide');
  281. for(var i = 2; i < parameters.length; i++){
  282. switch(i) {
  283. // 数据集uuid待完成
  284. // case (2):
  285. // console.log(1)
  286. // break;
  287. // $("#trainjob_datasets").val(parameters[i]);
  288. // console.log($("#trainjob_datasets").val())
  289. case (3):
  290. $("input[name='boot_file']").val(parameters[i]);
  291. break;
  292. case (4):
  293. var para = parameters[i].split(" ")
  294. for(var j = 0; j < para.length; j++){
  295. var para_name = para[j].split('=')[0]
  296. var para_value = para[j].split('=')[1]
  297. var len = $(".dynamic.field .two.fields").length
  298. Add_parameter(len)
  299. var pid = 'para' + len
  300. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_first-name]").val(para_name)
  301. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_last-name]").val(para_value)
  302. }
  303. break;
  304. // 数据集pool_id待完成
  305. // case (5):
  306. // $("select[name='pool_id']").val(parameters[i]);
  307. // break;
  308. case (6):
  309. $("input[name='work_server_number']").val(parameters[i]);
  310. break;
  311. }
  312. }
  313. })
  314. $('.ui.save.checkbox').click(function(){
  315. $(this).checkbox({
  316. onChange: function(){
  317. if ($('.ui.save.checkbox').checkbox('is checked')){
  318. $('#save_para').removeClass("disabled")
  319. }else{
  320. $('#save_para').addClass("disabled")
  321. }
  322. }
  323. });
  324. })
  325. $('.question.circle.icon').hover(function(){
  326. $(this).popup('show')
  327. });
  328. $(".item.active.parameter_config").click(function(){
  329. $('.ui.parameter.modal')
  330. .modal('setting', 'closable', false)
  331. .modal('show');
  332. })
  333. $('.ui.deny.button').click(function(){
  334. $('.ui.parameter.modal')
  335. .modal('hide');
  336. })
  337. $('select.dropdown')
  338. .dropdown();
  339. $('.ui.form')
  340. .form({
  341. on: 'blur',
  342. inline:true,
  343. fields: {
  344. boot_file: {
  345. identifier : 'boot_file',
  346. rules: [
  347. {
  348. type: 'regExp[/.+\.py$/g]',
  349. prompt : '启动文件必须为.py结尾'
  350. }
  351. ]
  352. },
  353. job_name:{
  354. identifier : 'job_name',
  355. rules: [
  356. {
  357. type: 'regExp[/^[a-zA-Z0-9-_]{1,36}$/]',
  358. prompt : '只包含大小写字母、数字、_和-,最长36个字符。'
  359. }
  360. ]
  361. },
  362. attachment:{
  363. identifier : 'attachment',
  364. rules: [
  365. {
  366. type: 'empty',
  367. prompt : '选择一个数据集'
  368. }
  369. ]
  370. },
  371. work_server_number: {
  372. identifier : 'work_server_number',
  373. rules: [
  374. {
  375. type : 'integer[1..25]',
  376. prompt : '计算节点需要在1-25之间,请您键入正确的值'
  377. }
  378. ]
  379. }
  380. },
  381. })
  382. function validate(){
  383. $('.ui.form')
  384. .form({
  385. on: 'blur',
  386. inline:true,
  387. fields: {
  388. boot_file: {
  389. identifier : 'boot_file',
  390. rules: [
  391. {
  392. type: 'regExp[/.+\.py$/g]',
  393. prompt : '启动文件必须为.py结尾'
  394. }
  395. ]
  396. },
  397. job_name:{
  398. identifier : 'job_name',
  399. rules: [
  400. {
  401. type: 'regExp[/^[a-zA-Z0-9-_]{1,36}$/]',
  402. prompt : '只包含大小写字母、数字、_和-,最长36个字符。'
  403. }
  404. ]
  405. },
  406. attachment:{
  407. identifier : 'attachment',
  408. rules: [
  409. {
  410. type: 'empty',
  411. prompt : '选择一个数据集'
  412. }
  413. ]
  414. },
  415. work_server_number: {
  416. identifier : 'work_server_number',
  417. rules: [
  418. {
  419. type : 'integer[1..25]',
  420. prompt : '计算节点需要在1-25之间,请您键入正确的值'
  421. }
  422. ]
  423. }
  424. },
  425. onSuccess: function(){
  426. // $('.ui.page.dimmer').dimmer('show')
  427. document.getElementById("mask").style.display = "block"
  428. },
  429. onFailure: function(e){
  430. return false;
  431. }
  432. })
  433. }
  434. document.onreadystatechange = function() {
  435. if (document.readyState === "complete") {
  436. document.getElementById("mask").style.display = "none"
  437. }
  438. }
  439. function send_run_para(){
  440. var run_parameters = []
  441. var msg = {}
  442. $(".dynamic.field .two.fields").each(function(){
  443. var para_name = $(this).find('input[name=shipping_first-name]').val()
  444. var para_value = $(this).find('input[name=shipping_last-name]').val()
  445. run_parameters.push({"label": para_name, "value": para_value})
  446. })
  447. msg["parameter"] = run_parameters
  448. msg = JSON.stringify(msg)
  449. $('#store_run_para').val(msg)
  450. }
  451. function get_name(){
  452. let name1=$("#engine_name .text").text()
  453. let name2=$("#flaver_name .text").text()
  454. $("input#ai_engine_name").val(name1)
  455. $("input#ai_flaver_name").val(name2)
  456. }
  457. $('.ui.create_train_job.green.button').click(function(e) {
  458. get_name()
  459. send_run_para()
  460. validate()
  461. })
  462. </script>