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

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