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