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.

version_new.tmpl 24 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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. .left2{
  97. margin-left: -2px;
  98. }
  99. @-webkit-keyframes sk-stretchdelay {
  100. 0%,
  101. 40%,
  102. 100% {
  103. -webkit-transform: scaleY(0.4)
  104. }
  105. 20% {
  106. -webkit-transform: scaleY(1.0)
  107. }
  108. }
  109. @keyframes sk-stretchdelay {
  110. 0%,
  111. 40%,
  112. 100% {
  113. transform: scaleY(0.4);
  114. -webkit-transform: scaleY(0.4);
  115. }
  116. 20% {
  117. transform: scaleY(1.0);
  118. -webkit-transform: scaleY(1.0);
  119. }
  120. }
  121. </style>
  122. <!-- <div class="ui page dimmer">
  123. <div class="ui text loader">{{.i18n.Tr "loading"}}</div>
  124. </div> -->
  125. <div id="mask">
  126. <div id="loadingPage">
  127. <div class="rect1"></div>
  128. <div class="rect2"></div>
  129. <div class="rect3"></div>
  130. <div class="rect4"></div>
  131. <div class="rect5"></div>
  132. </div>
  133. </div>
  134. <div class="repository">
  135. {{template "repo/header" .}}
  136. <div class="ui container">
  137. {{template "base/alert" .}}
  138. <h4 class="ui top attached header">
  139. {{.i18n.Tr "repo.modelarts.train_job.new"}}
  140. </h4>
  141. <div class="ui attached segment">
  142. <!-- equal width -->
  143. <form class="ui form" action="{{$.RepoLink}}/modelarts/train-job/{{.JobID}}/create_version" method="post">
  144. {{.CsrfTokenHtml}}
  145. <input type="hidden" name="action" value="update">
  146. <input type="hidden" name="version_name" value="">
  147. <input type="hidden" id="ai_engine_name" name="engine_names" value="">
  148. <input type="hidden" id="ai_flaver_name" name="flaver_names" value="">
  149. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4>
  150. <div class="required unite min_title inline field">
  151. <label>{{.i18n.Tr "repo.modelarts.train_job.job_name"}}</label>
  152. <input type="hidden" style="width: 60%;" name="job_name" id="trainjob_job_name" value="{{.job_name}}">
  153. <input style="width: 60%;" value="{{.job_name}}" tabindex="3" disabled >
  154. </div>
  155. <div class="required unite min_title inline field">
  156. <label>{{.i18n.Tr "repo.modelarts.parents_version"}}</label>
  157. <input id="parents_version" style="width: 60%;" value="" tabindex="3" disabled >
  158. </div>
  159. <div class="unite min_title inline field">
  160. <label for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}&nbsp;&nbsp;</label>
  161. <textarea style="width: 80%;" id="description" value="{{.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, 256)">{{.description}}</textarea>
  162. </div>
  163. <div class="ui divider"></div>
  164. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:</h4>
  165. <div class="required unite min_title inline field">
  166. <label>{{.i18n.Tr "repo.modelarts.code_version"}}</label>
  167. <select class="ui dropdown width80 left2" id="code_version" name="branch_name">
  168. {{if .branch_name}}
  169. <option name="branch_name" value="{{.branch_name}}">{{.branch_name}}</option>
  170. {{end}}
  171. {{range $k, $v :=.branches}}
  172. {{if ne $.branch_name $v}}
  173. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  174. {{end}}
  175. {{end}}
  176. </select>
  177. </div>
  178. <div class="required unite min_title inline fields" style="width: 90%;">
  179. <label>{{.i18n.Tr "repo.modelarts.train_job.AI_driver"}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
  180. <div class="field" style="flex: 1.5;">
  181. <select class="ui dropdown width" id="trainjob_engines" >
  182. {{range .engines}}
  183. <option value="{{.Value}}">{{.Value}}</option>
  184. {{end}}
  185. </select>
  186. </div>
  187. <div class="field" style="flex: 2;" id="engine_name">
  188. <select class="ui dropdown width" id="trainjob_engine_versions" style='width: 100%;' name="engine_id">
  189. {{if .engine_id}}
  190. <option name="engine_id" value="{{.engine_id}}">{{.engine_name}}</option>
  191. {{end}}
  192. {{range .engine_versions}}
  193. {{if ne $.engine_id .ID}}
  194. <option name="engine_id" value="{{.ID}}">{{.Value}}</option>
  195. {{end}}
  196. {{end}}
  197. </select>
  198. </div>
  199. </div>
  200. <div class="inline unite min_title field required">
  201. <label>{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label>
  202. {{if .boot_file}}
  203. <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="{{.boot_file}}" tabindex="3" autofocus required maxlength="255" >
  204. {{else}}
  205. <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255" >
  206. {{end}}
  207. <span>
  208. <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>
  209. </span>
  210. </div>
  211. <div class="required unite min_title inline field">
  212. <label>{{.i18n.Tr "repo.modelarts.train_job.dataset"}}</label>
  213. <select class="ui dropdown width80" id="trainjob_datasets" name="attachment" placeholder="选择数据集">
  214. {{if .dataset_name}}
  215. <option name="attachment" value="{{.uuid}}">{{.dataset_name}}</option>
  216. {{end}}
  217. {{range .attachments}}
  218. <option value="">选择数据集</option>
  219. {{if ne $.uuid .UUID}}
  220. <option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option>
  221. {{end}}
  222. {{end}}
  223. </select>
  224. </div>
  225. <div class="inline unite min_title field">
  226. <label>{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label>
  227. <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>
  228. <input id="store_run_para" type="hidden" name="run_para_list">
  229. <div class="dynamic field" style="margin-top: 1rem;">
  230. {{if ne 0 (len .params)}}
  231. {{range $k ,$v := .params}}
  232. <div class="two fields width85" id="para{{$k}}">
  233. <div class="field">
  234. <input type="text" name="shipping_first-name" value={{$v.Label}} required>
  235. </div>
  236. <div class="field">
  237. <input type="text" name="shipping_last-name" value={{$v.Value}} required>
  238. </div>
  239. <span>
  240. <i class="trash icon"></i>
  241. </span>
  242. </div>
  243. {{end}}
  244. {{end}}
  245. </div>
  246. </div>
  247. <div class="required field " style="display: none;">
  248. <label>{{.i18n.Tr "repo.modelarts.train_job.resource_pool"}}</label>
  249. <select class="ui dropdown" id="trainjob_resource_pool" style='width:385px' name="pool_id">
  250. {{range .resource_pools}}
  251. <option value="{{.ID}}">{{.Value}}</option>
  252. {{end}}
  253. </select>
  254. </div>
  255. <div class="required grouped fields" style="display: none;">
  256. <label for="resource_type">{{.i18n.Tr "repo.modelarts.train_job.resource_type"}}</label>
  257. <div class="field">
  258. <div class="ui grid">
  259. <div class="column">
  260. <div class="ui radio checkbox">
  261. <input type="radio" name="resource_type" checked="" tabindex="0">
  262. </div>
  263. </div>
  264. <div class="three wide column">train-private-1</div>
  265. <div class="three wide column">{{svg "octicon-verified" 16}} 运行中</div>
  266. <div class="three wide column"> CPU:192 核 2048GiB</div>
  267. </div>
  268. </div>
  269. </div>
  270. <div class="required unite min_title inline field" id="flaver_name">
  271. <label>{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label>
  272. <select class="ui dropdown width81" id="trainjob-flavor" style='width:385px' name="flavor">
  273. {{if .flavor_name}}
  274. <option name="flavor" value="{{.flavor_code}}">{{.flavor_name}}</option>
  275. {{end}}
  276. {{range .flavor_infos}}
  277. {{if ne $.flavor_code .Code}}
  278. <option name="flavor" value="{{.Code}}">{{.Value}}</option>
  279. {{end}}
  280. {{end}}
  281. </select>
  282. </div>
  283. <div class="inline required unite min_title field">
  284. <label>{{.i18n.Tr "repo.modelarts.train_job.amount_of_compute_node"}}</label>
  285. <div class="ui labeled input" style="width: 5%;">
  286. <input style="border-radius: 0;text-align: center;" name="work_server_number" id="trainjob_work_server_num" tabindex="3" autofocus required maxlength="255" value="{{.work_server_number}}" readonly>
  287. </div>
  288. </div>
  289. <div class="inline unite min_title field">
  290. <button class="ui create_train_job green button">
  291. {{.i18n.Tr "repo.cloudbrain.new"}}
  292. </button>
  293. <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  294. </div>
  295. <!-- 模态框 -->
  296. </form>
  297. </div>
  298. </div>
  299. </div>
  300. {{template "base/footer" .}}
  301. <script>
  302. let url_href = {{.RepoLink}}+'/modelarts/train-job'
  303. let url_post = location.pathname
  304. let version_name = location.search.split('?version_name=')[1]
  305. $("#parents_version").val(version_name)
  306. $(".ui.button").attr('href',url_href)
  307. $(".ui.form").attr('action',url_post)
  308. $("input[name=version_name]").attr('value',version_name)
  309. $('select.dropdown')
  310. .dropdown();
  311. $('.menu .item')
  312. .tab();
  313. let sever_num = $('#trainjob_work_server_num')
  314. $('.add').click(function(){
  315. sever_num.val(parseInt(sever_num.val())+1)
  316. if(sever_num.val()>=26){
  317. sever_num.val(parseInt(sever_num.val())-1)
  318. }
  319. })
  320. $('.min').click(function(){
  321. sever_num.val(parseInt(sever_num.val())-1)
  322. if(sever_num.val()<=0){
  323. sever_num.val(parseInt(sever_num.val())+1)
  324. }
  325. })
  326. // 参数增加、删除、修改、保存
  327. function Add_parameter(i){
  328. value = '<div class="two fields width85" id= "para'+ i +'">' +
  329. '<div class="field">' +
  330. '<input type="text" name="shipping_first-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}> ' +
  331. '</div> ' +
  332. '<div class="field"> ' +
  333. '<input type="text" name="shipping_last-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}>' +
  334. '</div>'+
  335. '<span>' +
  336. '<i class="trash icon">' +
  337. '</i>' +
  338. '</span>' +
  339. '</div>'
  340. $(".dynamic.field").append(value)
  341. }
  342. $('#add_run_para').click(function(){
  343. var len = $(".dynamic.field .two.fields").length
  344. Add_parameter(len)
  345. });
  346. $(".dynamic.field").on("click",".trash.icon", function() {
  347. var index = $(this).parent().parent().index()
  348. $(this).parent().parent().remove()
  349. var len = $(".dynamic.field .two.fields").length
  350. $(".dynamic.field .two.fields").each(function(){
  351. var cur_index = $(this).index()
  352. $(this).attr('id', 'para' + cur_index)
  353. })
  354. });
  355. $('.ui.parameter.green.button').click(function(){
  356. var parameters = [];
  357. $('table tr').each(function() {
  358. $(this).find('td:eq(1)').each(function(){
  359. parameters.push($(this).text());
  360. })
  361. $(this).find('input').each(function(){
  362. parameters.push($(this).text())
  363. })
  364. });
  365. $('.ui.parameter.modal')
  366. .modal('hide');
  367. for(var i = 2; i < parameters.length; i++){
  368. switch(i) {
  369. // 数据集uuid待完成
  370. // case (2):
  371. // console.log(1)
  372. // break;
  373. // $("#trainjob_datasets").val(parameters[i]);
  374. // console.log($("#trainjob_datasets").val())
  375. case (3):
  376. $("input[name='boot_file']").val(parameters[i]);
  377. break;
  378. case (4):
  379. var para = parameters[i].split(" ")
  380. for(var j = 0; j < para.length; j++){
  381. var para_name = para[j].split('=')[0]
  382. var para_value = para[j].split('=')[1]
  383. var len = $(".dynamic.field .two.fields").length
  384. Add_parameter(len)
  385. var pid = 'para' + len
  386. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_first-name]").val(para_name)
  387. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_last-name]").val(para_value)
  388. }
  389. break;
  390. // 数据集pool_id待完成
  391. // case (5):
  392. // $("select[name='pool_id']").val(parameters[i]);
  393. // break;
  394. case (6):
  395. $("input[name='work_server_number']").val(parameters[i]);
  396. break;
  397. }
  398. }
  399. })
  400. $('.ui.save.checkbox').click(function(){
  401. $(this).checkbox({
  402. onChange: function(){
  403. if ($('.ui.save.checkbox').checkbox('is checked')){
  404. $('#save_para').removeClass("disabled")
  405. }else{
  406. $('#save_para').addClass("disabled")
  407. }
  408. }
  409. });
  410. })
  411. $('.question.circle.icon').hover(function(){
  412. $(this).popup('show')
  413. });
  414. $(".item.active.parameter_config").click(function(){
  415. $('.ui.parameter.modal')
  416. .modal('setting', 'closable', false)
  417. .modal('show');
  418. })
  419. $('.ui.deny.button').click(function(){
  420. $('.ui.parameter.modal')
  421. .modal('hide');
  422. })
  423. $('select.dropdown')
  424. .dropdown();
  425. $('.ui.form')
  426. .form({
  427. on: 'blur',
  428. inline:true,
  429. fields: {
  430. boot_file: {
  431. identifier : 'boot_file',
  432. rules: [
  433. {
  434. type: 'regExp[/.+\.py$/g]',
  435. prompt : '启动文件必须为.py结尾'
  436. }
  437. ]
  438. },
  439. job_name:{
  440. identifier : 'job_name',
  441. rules: [
  442. {
  443. type: 'regExp[/^[a-zA-Z0-9-_]{1,36}$/]',
  444. prompt : '只包含大小写字母、数字、_和-,最长36个字符。'
  445. }
  446. ]
  447. },
  448. attachment:{
  449. identifier : 'attachment',
  450. rules: [
  451. {
  452. type: 'empty',
  453. prompt : '选择一个数据集'
  454. }
  455. ]
  456. },
  457. work_server_number: {
  458. identifier : 'work_server_number',
  459. rules: [
  460. {
  461. type : 'integer[1..25]',
  462. prompt : '计算节点需要在1-25之间,请您键入正确的值'
  463. }
  464. ]
  465. },
  466. run_para_list:{
  467. identifier : 'run_para_list',
  468. rules: [
  469. {
  470. type: 'maxLength[256]',
  471. prompt : '所有字符最长不超过256个字符。'
  472. }
  473. ]
  474. },
  475. },
  476. })
  477. function validate(){
  478. $('.ui.form')
  479. .form({
  480. on: 'blur',
  481. inline:true,
  482. fields: {
  483. boot_file: {
  484. identifier : 'boot_file',
  485. rules: [
  486. {
  487. type: 'regExp[/.+\.py$/g]',
  488. prompt : '启动文件必须为.py结尾'
  489. }
  490. ]
  491. },
  492. job_name:{
  493. identifier : 'job_name',
  494. rules: [
  495. {
  496. type: 'regExp[/^[a-zA-Z0-9-_]{1,36}$/]',
  497. prompt : '只包含大小写字母、数字、_和-,最长36个字符。'
  498. }
  499. ]
  500. },
  501. attachment:{
  502. identifier : 'attachment',
  503. rules: [
  504. {
  505. type: 'empty',
  506. prompt : '选择一个数据集'
  507. }
  508. ]
  509. },
  510. work_server_number: {
  511. identifier : 'work_server_number',
  512. rules: [
  513. {
  514. type : 'integer[1..25]',
  515. prompt : '计算节点需要在1-25之间,请您键入正确的值'
  516. }
  517. ]
  518. },
  519. run_para_list:{
  520. identifier : 'run_para_list',
  521. rules: [
  522. {
  523. type: 'maxLength[256]',
  524. prompt : '所有字符最长不超过256个字符。'
  525. }
  526. ]
  527. },
  528. },
  529. onSuccess: function(){
  530. // $('.ui.page.dimmer').dimmer('show')
  531. document.getElementById("mask").style.display = "block"
  532. },
  533. onFailure: function(e){
  534. return false;
  535. }
  536. })
  537. }
  538. document.onreadystatechange = function() {
  539. if (document.readyState === "complete") {
  540. document.getElementById("mask").style.display = "none"
  541. }
  542. }
  543. function send_run_para(){
  544. var run_parameters = []
  545. var msg = {}
  546. $(".dynamic.field .two.fields").each(function(){
  547. var para_name = $(this).find('input[name=shipping_first-name]').val()
  548. var para_value = $(this).find('input[name=shipping_last-name]').val()
  549. run_parameters.push({"label": para_name, "value": para_value})
  550. })
  551. msg["parameter"] = run_parameters
  552. msg = JSON.stringify(msg)
  553. $('#store_run_para').val(msg)
  554. }
  555. function get_name(){
  556. let name1=$("#engine_name .text").text()
  557. let name2=$("#flaver_name .text").text()
  558. console.log(name1,name2)
  559. $("input#ai_engine_name").val(name1)
  560. $("input#ai_flaver_name").val(name2)
  561. }
  562. $('.ui.create_train_job.green.button').click(function(e) {
  563. get_name()
  564. send_run_para()
  565. validate()
  566. })
  567. </script>