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 23 kB

3 years ago
3 years ago
4 years ago
3 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
3 years ago
4 years ago
4 years ago
4 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
3 years ago
4 years ago
4 years ago
4 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
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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. #mask {
  49. position: fixed;
  50. top: 0px;
  51. left: 0px;
  52. right: 0px;
  53. bottom: 0px;
  54. filter: alpha(opacity=60);
  55. background-color: #777;
  56. z-index: 1000;
  57. display: none;
  58. opacity: 0.8;
  59. -moz-opacity: 0.5;
  60. padding-top: 100px;
  61. color: #000000
  62. }
  63. /* 加载圈css效果图 */
  64. #loadingPage {
  65. margin: 200px auto;
  66. width: 50px;
  67. height: 40px;
  68. text-align: center;
  69. font-size: 10px;
  70. display: block;
  71. }
  72. #loadingPage>div {
  73. background-color: green;
  74. height: 100%;
  75. width: 6px;
  76. display: inline-block;
  77. -webkit-animation: sk-stretchdelay 1.2s infinite ease-in-out;
  78. animation: sk-stretchdelay 1.2s infinite ease-in-out;
  79. }
  80. #loadingPage .rect2 {
  81. -webkit-animation-delay: -1.1s;
  82. animation-delay: -1.1s;
  83. }
  84. #loadingPage .rect3 {
  85. -webkit-animation-delay: -1.0s;
  86. animation-delay: -1.0s;
  87. }
  88. #loadingPage .rect4 {
  89. -webkit-animation-delay: -0.9s;
  90. animation-delay: -0.9s;
  91. }
  92. #loadingPage .rect5 {
  93. -webkit-animation-delay: -0.8s;
  94. animation-delay: -0.8s;
  95. }
  96. @-webkit-keyframes sk-stretchdelay {
  97. 0%,
  98. 40%,
  99. 100% {
  100. -webkit-transform: scaleY(0.4)
  101. }
  102. 20% {
  103. -webkit-transform: scaleY(1.0)
  104. }
  105. }
  106. @keyframes sk-stretchdelay {
  107. 0%,
  108. 40%,
  109. 100% {
  110. transform: scaleY(0.4);
  111. -webkit-transform: scaleY(0.4);
  112. }
  113. 20% {
  114. transform: scaleY(1.0);
  115. -webkit-transform: scaleY(1.0);
  116. }
  117. }
  118. </style>
  119. <!-- <div class="ui page dimmer">
  120. <div class="ui text loader">{{.i18n.Tr "loading"}}</div>
  121. </div> -->
  122. <div id="mask">
  123. <div id="loadingPage">
  124. <div class="rect1"></div>
  125. <div class="rect2"></div>
  126. <div class="rect3"></div>
  127. <div class="rect4"></div>
  128. <div class="rect5"></div>
  129. </div>
  130. </div>
  131. <div class="repository">
  132. {{template "repo/header" .}}
  133. <div class="ui container">
  134. {{template "base/alert" .}}
  135. <h4 class="ui top attached header">
  136. {{.i18n.Tr "repo.modelarts.train_job.new"}}
  137. </h4>
  138. <div class="ui attached segment">
  139. <!-- equal width -->
  140. <form class="ui form" action="{{.Link}}" method="post">
  141. {{.CsrfTokenHtml}}
  142. <input type="hidden" name="action" value="update">
  143. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4>
  144. <div class="required unite min_title inline field">
  145. <label>{{.i18n.Tr "repo.modelarts.train_job.job_name"}}</label>
  146. <input style="width: 80%;" name="job_name" id="trainjob_job_name" placeholder={{.i18n.Tr "repo.modelarts.train_job.job_name"}} value="{{.job_name}}" tabindex="3" autofocus required maxlength="255">
  147. </div>
  148. <!--<div class="inline field">
  149. <label>{{.i18n.Tr "repo.modelarts.train_job.version"}}</label>
  150. <span>第一版本</span>
  151. </div>
  152. -->
  153. <div class="unite min_title inline field">
  154. <label for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}&nbsp;&nbsp;</label>
  155. <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="256" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} onchange="this.value=this.value.substring(0, 256)" onkeydown="this.value=this.value.substring(0, 256)" onkeyup="this.value=this.value.substring(0, 256)"></textarea>
  156. </div>
  157. <!-- <h4 class="ui dividing header">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}</h4>
  158. <div class="inline field">
  159. <label>{{.i18n.Tr "repo.modelarts.train_job.fast_parameter_setting"}}</label>
  160. <span>
  161. {{.i18n.Tr "repo.modelarts.train_job.fast_parameter_setting_config"}}
  162. <a class="item active parameter_config">{{.i18n.Tr "repo.modelarts.train_job.fast_parameter_setting_config_link"}}</a>
  163. </span>
  164. </div> -->
  165. <div class="ui divider"></div>
  166. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:</h4>
  167. <div class="required unite min_title inline fields" style="width: 90%;">
  168. <label>{{.i18n.Tr "repo.modelarts.train_job.AI_driver"}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
  169. <div class="field" style="flex: 1.5;">
  170. <select class="ui search dropdown width" id="trainjob_engines" >
  171. {{range .engines}}
  172. <option value="{{.Value}}">{{.Value}}</option>
  173. {{end}}
  174. </select>
  175. </div>
  176. <div class="field" style="flex: 2;">
  177. <select class="ui search dropdown width" id="trainjob_engine_versions" style='width: 100%;' name="engine_id">
  178. {{range .engine_versions}}
  179. <option name="engine_id" value="{{.ID}}">{{.Value}}</option>
  180. {{end}}
  181. </select>
  182. </div>
  183. </div>
  184. <!-- <div class="required inline field">
  185. <label>{{.i18n.Tr "repo.modelarts.train_job.algorithm_origin"}}</label>
  186. <div class="ui top attached tabular menu">
  187. <a class="item active" data-tab="frame">{{svg "octicon-repo" 16}}{{.i18n.Tr "repo.modelarts.train_job.frames"}}</a>
  188. </div>
  189. <div class="ui bottom attached tab active segment" data-tab="frame">
  190. <div class="required field">
  191. <label>{{.i18n.Tr "repo.modelarts.train_job.AI_driver"}}</label>
  192. <div class="two fields">
  193. <div class="field">
  194. <select class="ui search dropdown" id="trainjob_engines" style='width:385px'>
  195. {{range .engines}}
  196. <option value="{{.Value}}">{{.Value}}</option>
  197. {{end}}
  198. </select>
  199. </div>
  200. <div class="field">
  201. <select class="ui search dropdown" id="trainjob_engine_versions" style='width:385px' name="engine_id">
  202. {{range .engine_versions}}
  203. <option name="engine_id" value="{{.ID}}">{{.Value}}</option>
  204. {{end}}
  205. </select>
  206. </div>
  207. </div>
  208. </div>
  209. <div class="inline required field">
  210. <label>{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label>
  211. <input name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255">
  212. <span>
  213. <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>
  214. </span>
  215. </div>
  216. </div>
  217. </div> -->
  218. <div class="inline unite min_title field required">
  219. <label>{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label>
  220. {{if .bootFile}}
  221. <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="{{.bootFile}}" tabindex="3" autofocus required maxlength="255" >
  222. {{else}}
  223. <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255" >
  224. {{end}}
  225. <span>
  226. <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>
  227. </span>
  228. </div>
  229. <div class="required unite min_title inline field">
  230. <label>{{.i18n.Tr "repo.modelarts.train_job.dataset"}}</label>
  231. <select class="ui search dropdown width80" id="trainjob_datasets" name="attachment">
  232. {{range .attachments}}
  233. {{if $.uuid}}
  234. <option name="attachment" value="{{$.uuid}}">{{$.datasetName}}</option>
  235. {{else}}
  236. <option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option>
  237. {{end}}
  238. {{end}}
  239. </select>
  240. </div>
  241. <div class="inline unite min_title field">
  242. <label>{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label>
  243. <!-- <i class="plus square outline icon"></i> -->
  244. <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>
  245. <input id="store_run_para" type="hidden" name="run_para_list">
  246. <div class="dynamic field" style="margin-top: 1rem;"></div>
  247. <!-- <div class="dynamic field">
  248. </div> -->
  249. </div>
  250. <!-- <h4 class="ui dividing header">{{.i18n.Tr "repo.modelarts.train_job.resource_setting"}}</h4> -->
  251. <div class="required field " style="display: none;">
  252. <label>{{.i18n.Tr "repo.modelarts.train_job.resource_pool"}}</label>
  253. <select class="ui search dropdown" id="trainjob_resource_pool" style='width:385px' name="pool_id">
  254. {{range .resource_pools}}
  255. <option value="{{.ID}}">{{.Value}}</option>
  256. {{end}}
  257. </select>
  258. </div>
  259. <div class="required grouped fields" style="display: none;">
  260. <label for="resource_type">{{.i18n.Tr "repo.modelarts.train_job.resource_type"}}</label>
  261. <div class="field">
  262. <div class="ui grid">
  263. <div class="column">
  264. <div class="ui radio checkbox">
  265. <input type="radio" name="resource_type" checked="" tabindex="0">
  266. </div>
  267. </div>
  268. <div class="three wide column">train-private-1</div>
  269. <div class="three wide column">{{svg "octicon-verified" 16}} 运行中</div>
  270. <div class="three wide column"> CPU:192 核 2048GiB</div>
  271. </div>
  272. </div>
  273. </div>
  274. <div class="required unite min_title inline field">
  275. <label>{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label>
  276. <select class="ui search dropdown width81" id="trainjob-flavor" style='width:385px' name="flavor">
  277. {{range .flavor_infos}}
  278. <option name="flavor" value="{{.Code}}">{{.Value}}</option>
  279. {{end}}
  280. </select>
  281. </div>
  282. <div class="inline required unite min_title field">
  283. <label>{{.i18n.Tr "repo.modelarts.train_job.amount_of_compute_node"}}</label>
  284. <div class="ui labeled input">
  285. <span class="min"><i class="minus icon"></i></span>
  286. <input style="border-radius: 0;" name="work_server_number" id="trainjob_work_server_num" tabindex="3" autofocus required maxlength="255" value="1">
  287. <span class="add"><i class="plus icon"></i></span>
  288. </div>
  289. <!-- <input name="work_server_number" id="trainjob_work_server_num" tabindex="3" autofocus required maxlength="255"> -->
  290. </div>
  291. <!--
  292. <div class="inline field">
  293. <div class="ui save checkbox">
  294. <input name="is_save_para" type="checkbox">
  295. <label>{{.i18n.Tr "repo.modelarts.train_job.query_whether_save_parameter"}}
  296. <span>
  297. <i class="question circle icon link" data-content={{.i18n.Tr "repo.modelarts.train_job.save_helper"}} data-position="right center" data-variation="mini"></i>
  298. </span>
  299. </label>
  300. </div>
  301. </div>
  302. <div class="disabled field" id="save_para">
  303. <div class="field">
  304. <label>{{.i18n.Tr "repo.modelarts.train_job.job_parameter_name"}}</label>
  305. <input name="parameter_template_name" id="parameter_template_name" tabindex="3" autofocus maxlength="255">
  306. </div>
  307. <div class="field">
  308. <label for="parameter_description">{{.i18n.Tr "repo.modelarts.train_job.parameter_description"}}</label>
  309. <textarea id="parameter_description" name="parameter_description" rows="2"></textarea>
  310. </div>
  311. </div>
  312. -->
  313. <div class="inline unite min_title field">
  314. <button class="ui create_train_job green button">
  315. {{.i18n.Tr "repo.cloudbrain.new"}}
  316. </button>
  317. <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  318. </div>
  319. <!-- 模态框 -->
  320. </form>
  321. </div>
  322. </div>
  323. </div>
  324. {{template "base/footer" .}}
  325. <script>
  326. let url_href = window.location.pathname.split('create')[0]
  327. $(".ui.button").attr('href',url_href)
  328. $('select.dropdown')
  329. .dropdown();
  330. $('.menu .item')
  331. .tab();
  332. let sever_num = $('#trainjob_work_server_num')
  333. $('.add').click(function(){
  334. sever_num.val(parseInt(sever_num.val())+1)
  335. })
  336. $('.min').click(function(){
  337. sever_num.val(parseInt(sever_num.val())-1)
  338. if(sever_num.val()<=0){
  339. sever_num.val(parseInt(sever_num.val())+1)
  340. }
  341. })
  342. // 参数增加、删除、修改、保存
  343. function Add_parameter(i){
  344. value = '<div class="two fields width85" id= "para'+ i +'">' +
  345. '<div class="field">' +
  346. '<input type="text" name="shipping_first-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}> ' +
  347. '</div> ' +
  348. '<div class="field"> ' +
  349. '<input type="text" name="shipping_last-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}>' +
  350. '</div>'+
  351. '<span>' +
  352. '<i class="trash icon">' +
  353. '</i>' +
  354. '</span>' +
  355. '</div>'
  356. $(".dynamic.field").append(value)
  357. }
  358. $('#add_run_para').click(function(){
  359. var len = $(".dynamic.field .two.fields").length
  360. Add_parameter(len)
  361. });
  362. $(".dynamic.field").on("click",".trash.icon", function() {
  363. var index = $(this).parent().parent().index()
  364. $(this).parent().parent().remove()
  365. var len = $(".dynamic.field .two.fields").length
  366. $(".dynamic.field .two.fields").each(function(){
  367. var cur_index = $(this).index()
  368. $(this).attr('id', 'para' + cur_index)
  369. })
  370. });
  371. $('.ui.parameter.green.button').click(function(){
  372. var parameters = [];
  373. $('table tr').each(function() {
  374. $(this).find('td:eq(1)').each(function(){
  375. parameters.push($(this).text());
  376. })
  377. $(this).find('input').each(function(){
  378. parameters.push($(this).text())
  379. })
  380. });
  381. console.log(parameters)
  382. $('.ui.parameter.modal')
  383. .modal('hide');
  384. for(var i = 2; i < parameters.length; i++){
  385. switch(i) {
  386. // 数据集uuid待完成
  387. // case (2):
  388. // console.log(1)
  389. // break;
  390. // $("#trainjob_datasets").val(parameters[i]);
  391. // console.log($("#trainjob_datasets").val())
  392. case (3):
  393. $("input[name='boot_file']").val(parameters[i]);
  394. break;
  395. case (4):
  396. var para = parameters[i].split(" ")
  397. for(var j = 0; j < para.length; j++){
  398. var para_name = para[j].split('=')[0]
  399. var para_value = para[j].split('=')[1]
  400. var len = $(".dynamic.field .two.fields").length
  401. Add_parameter(len)
  402. var pid = 'para' + len
  403. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_first-name]").val(para_name)
  404. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_last-name]").val(para_value)
  405. }
  406. break;
  407. // 数据集pool_id待完成
  408. // case (5):
  409. // $("select[name='pool_id']").val(parameters[i]);
  410. // break;
  411. case (6):
  412. $("input[name='work_server_number']").val(parameters[i]);
  413. break;
  414. }
  415. }
  416. })
  417. $('.ui.save.checkbox').click(function(){
  418. $(this).checkbox({
  419. onChange: function(){
  420. if ($('.ui.save.checkbox').checkbox('is checked')){
  421. $('#save_para').removeClass("disabled")
  422. }else{
  423. $('#save_para').addClass("disabled")
  424. }
  425. }
  426. });
  427. })
  428. $('.question.circle.icon').hover(function(){
  429. $(this).popup('show')
  430. });
  431. $(".item.active.parameter_config").click(function(){
  432. $('.ui.parameter.modal')
  433. .modal('setting', 'closable', false)
  434. .modal('show');
  435. })
  436. $('.ui.deny.button').click(function(){
  437. $('.ui.parameter.modal')
  438. .modal('hide');
  439. })
  440. function validate(){
  441. $('.ui.form')
  442. .form({
  443. on: 'blur',
  444. inline:true,
  445. fields: {
  446. boot_file: {
  447. identifier : 'boot_file',
  448. rules: [
  449. {
  450. type: 'regExp[/.+\.py$/g]',
  451. prompt : '启动文件必须为.py结尾'
  452. }
  453. ]
  454. },
  455. work_server_number: {
  456. identifier : 'work_server_number',
  457. rules: [
  458. {
  459. type : 'integer[1..25]',
  460. prompt : '计算节点需要在1-25之间,请您键入正确的值'
  461. }
  462. ]
  463. }
  464. },
  465. onSuccess: function(){
  466. // $('.ui.page.dimmer').dimmer('show')
  467. document.getElementById("mask").style.display = "block"
  468. },
  469. onFailure: function(e){
  470. return false;
  471. }
  472. })
  473. }
  474. document.onreadystatechange = function() {
  475. if (document.readyState === "complete") {
  476. document.getElementById("mask").style.display = "none"
  477. }
  478. }
  479. function send_run_para(){
  480. var run_parameters = []
  481. var msg = {}
  482. $(".dynamic.field .two.fields").each(function(){
  483. var para_name = $(this).find('input[name=shipping_first-name]').val()
  484. var para_value = $(this).find('input[name=shipping_last-name]').val()
  485. run_parameters.push({"label": para_name, "value": para_value})
  486. })
  487. msg["parameter"] = run_parameters
  488. msg = JSON.stringify(msg)
  489. $('#store_run_para').val(msg)
  490. }
  491. $('.ui.create_train_job.green.button').click(function(e) {
  492. send_run_para()
  493. validate()
  494. })
  495. </script>