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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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. <div class="required unite min_title inline field">
  76. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.job_name"}}</label>
  77. <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">
  78. </div>
  79. <div class="unite min_title inline field">
  80. <label style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}&nbsp;&nbsp;</label>
  81. <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>
  82. </div>
  83. <div class="required unite min_title inline fields" style="width: 90%;">
  84. <label style="font-weight: normal;">{{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_type"}}</label>
  85. <div class="field" style="flex: 1.5;">
  86. <select class="ui dropdown width" id="trainjob_engines" >
  87. {{range .engines}}
  88. <option value="{{.Value}}">{{.Value}}</option>
  89. {{end}}
  90. </select>
  91. </div>
  92. <label style="font-weight: normal;">{{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_child_type"}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
  93. <div class="field" style="flex: 2;" id="engine_name">
  94. <select class="ui dropdown width" id="trainjob_engine_versions" style='width: 100%;' name="engine_id">
  95. {{range .engine_versions}}
  96. <option name="engine_id" value="{{.ID}}">{{.Value}}</option>
  97. {{end}}
  98. </select>
  99. </div>
  100. </div>
  101. <div class="required unite min_title inline field">
  102. <label style="font-weight: normal;">{{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_mirror"}}&nbsp;&nbsp;&nbsp;</label>
  103. <select class="ui dropdown width80" id="trainjob_datasets" name="attachment" placeholder="选择镜像">
  104. {{if $.uuid}}
  105. <option name="attachment" value="{{$.uuid}}">{{$.datasetName}}</option>
  106. {{end}}
  107. {{range .attachments}}
  108. <option value="">选择镜像</option>
  109. <option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option>
  110. {{end}}
  111. </select>
  112. </div>
  113. <div class="inline unite min_title field required">
  114. <label style="font-weight: normal;">{{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_train"}}</label>
  115. <input style="width: 33.5%;" name="train_file" id="train_file" value="train.py" tabindex="3" autofocus required maxlength="254" >
  116. <a href="https://git.openi.org.cn/OpenIOSSG/MINIST_Example" target="_blank">查看样例</a>
  117. </div>
  118. <div class="inline unite min_title field required">
  119. <label style="font-weight: normal;">{{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_test"}}</label>
  120. <input style="width: 33.5%;" name="test_file" id="test_file" value="test.py" tabindex="3" autofocus required maxlength="254" >
  121. <a href="https://git.openi.org.cn/OpenIOSSG/MINIST_Example" target="_blank">查看样例</a>
  122. </div>
  123. <div class="inline unite min_title field">
  124. <button class="ui create_train_job green button">
  125. {{.i18n.Tr "repo.cloudbrain.new"}}
  126. </button>
  127. <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  128. </div>
  129. <!-- 模态框 -->
  130. </form>
  131. </div>
  132. </div>
  133. </div>
  134. {{template "base/footer" .}}
  135. <script>
  136. let url_href = window.location.pathname.split('create')[0]
  137. $(".ui.button").attr('href',url_href)
  138. $('select.dropdown')
  139. .dropdown();
  140. $('.menu .item')
  141. .tab();
  142. let sever_num = $('#trainjob_work_server_num')
  143. $('.add').click(function(){
  144. sever_num.val(parseInt(sever_num.val())+1)
  145. if(sever_num.val()>=26){
  146. sever_num.val(parseInt(sever_num.val())-1)
  147. }
  148. })
  149. $('.min').click(function(){
  150. sever_num.val(parseInt(sever_num.val())-1)
  151. if(sever_num.val()<=0){
  152. sever_num.val(parseInt(sever_num.val())+1)
  153. }
  154. })
  155. // 参数增加、删除、修改、保存
  156. function Add_parameter(i){
  157. value = '<div class="two fields width85" id= "para'+ i +'">' +
  158. '<div class="field">' +
  159. '<input type="text" name="shipping_first-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}> ' +
  160. '</div> ' +
  161. '<div class="field"> ' +
  162. '<input type="text" name="shipping_last-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}>' +
  163. '</div>'+
  164. '<span>' +
  165. '<i class="trash icon">' +
  166. '</i>' +
  167. '</span>' +
  168. '</div>'
  169. $(".dynamic.field").append(value)
  170. }
  171. $('#add_run_para').click(function(){
  172. var len = $(".dynamic.field .two.fields").length
  173. Add_parameter(len)
  174. });
  175. $(".dynamic.field").on("click",".trash.icon", function() {
  176. var index = $(this).parent().parent().index()
  177. $(this).parent().parent().remove()
  178. var len = $(".dynamic.field .two.fields").length
  179. $(".dynamic.field .two.fields").each(function(){
  180. var cur_index = $(this).index()
  181. $(this).attr('id', 'para' + cur_index)
  182. })
  183. });
  184. $('.ui.parameter.green.button').click(function(){
  185. var parameters = [];
  186. $('table tr').each(function() {
  187. $(this).find('td:eq(1)').each(function(){
  188. parameters.push($(this).text());
  189. })
  190. $(this).find('input').each(function(){
  191. parameters.push($(this).text())
  192. })
  193. });
  194. console.log(parameters)
  195. $('.ui.parameter.modal')
  196. .modal('hide');
  197. for(var i = 2; i < parameters.length; i++){
  198. switch(i) {
  199. // 数据集uuid待完成
  200. // case (2):
  201. // console.log(1)
  202. // break;
  203. // $("#trainjob_datasets").val(parameters[i]);
  204. // console.log($("#trainjob_datasets").val())
  205. case (3):
  206. $("input[name='boot_file']").val(parameters[i]);
  207. break;
  208. case (4):
  209. var para = parameters[i].split(" ")
  210. for(var j = 0; j < para.length; j++){
  211. var para_name = para[j].split('=')[0]
  212. var para_value = para[j].split('=')[1]
  213. var len = $(".dynamic.field .two.fields").length
  214. Add_parameter(len)
  215. var pid = 'para' + len
  216. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_first-name]").val(para_name)
  217. $(".dynamic.field"+ " #" + pid + "").find("input[name=shipping_last-name]").val(para_value)
  218. }
  219. break;
  220. // 数据集pool_id待完成
  221. // case (5):
  222. // $("select[name='pool_id']").val(parameters[i]);
  223. // break;
  224. case (6):
  225. $("input[name='work_server_number']").val(parameters[i]);
  226. break;
  227. }
  228. }
  229. })
  230. $('.ui.save.checkbox').click(function(){
  231. $(this).checkbox({
  232. onChange: function(){
  233. if ($('.ui.save.checkbox').checkbox('is checked')){
  234. $('#save_para').removeClass("disabled")
  235. }else{
  236. $('#save_para').addClass("disabled")
  237. }
  238. }
  239. });
  240. })
  241. $('.question.circle.icon').hover(function(){
  242. $(this).popup('show')
  243. });
  244. $(".item.active.parameter_config").click(function(){
  245. $('.ui.parameter.modal')
  246. .modal('setting', 'closable', false)
  247. .modal('show');
  248. })
  249. $('.ui.deny.button').click(function(){
  250. $('.ui.parameter.modal')
  251. .modal('hide');
  252. })
  253. $('select.dropdown')
  254. .dropdown();
  255. $('.ui.form')
  256. .form({
  257. on: 'blur',
  258. inline:true,
  259. fields: {
  260. boot_file: {
  261. identifier : 'boot_file',
  262. rules: [
  263. {
  264. type: 'regExp[/.+\.py$/g]',
  265. prompt : '启动文件必须为.py结尾'
  266. }
  267. ]
  268. },
  269. job_name:{
  270. identifier : 'job_name',
  271. rules: [
  272. {
  273. type: 'regExp[/^[a-zA-Z0-9-_]{1,36}$/]',
  274. prompt : '只包含大小写字母、数字、_和-,最长36个字符。'
  275. }
  276. ]
  277. },
  278. attachment:{
  279. identifier : 'attachment',
  280. rules: [
  281. {
  282. type: 'empty',
  283. prompt : '选择一个数据集'
  284. }
  285. ]
  286. },
  287. work_server_number: {
  288. identifier : 'work_server_number',
  289. rules: [
  290. {
  291. type : 'integer[1..25]',
  292. prompt : '计算节点需要在1-25之间,请您键入正确的值'
  293. }
  294. ]
  295. }
  296. },
  297. })
  298. function validate(){
  299. $('.ui.form')
  300. .form({
  301. on: 'blur',
  302. inline:true,
  303. fields: {
  304. boot_file: {
  305. identifier : 'boot_file',
  306. rules: [
  307. {
  308. type: 'regExp[/.+\.py$/g]',
  309. prompt : '启动文件必须为.py结尾'
  310. }
  311. ]
  312. },
  313. job_name:{
  314. identifier : 'job_name',
  315. rules: [
  316. {
  317. type: 'regExp[/^[a-zA-Z0-9-_]{1,36}$/]',
  318. prompt : '只包含大小写字母、数字、_和-,最长36个字符。'
  319. }
  320. ]
  321. },
  322. attachment:{
  323. identifier : 'attachment',
  324. rules: [
  325. {
  326. type: 'empty',
  327. prompt : '选择一个数据集'
  328. }
  329. ]
  330. },
  331. work_server_number: {
  332. identifier : 'work_server_number',
  333. rules: [
  334. {
  335. type : 'integer[1..25]',
  336. prompt : '计算节点需要在1-25之间,请您键入正确的值'
  337. }
  338. ]
  339. }
  340. },
  341. onSuccess: function(){
  342. // $('.ui.page.dimmer').dimmer('show')
  343. document.getElementById("mask").style.display = "block"
  344. },
  345. onFailure: function(e){
  346. return false;
  347. }
  348. })
  349. }
  350. document.onreadystatechange = function() {
  351. if (document.readyState === "complete") {
  352. document.getElementById("mask").style.display = "none"
  353. }
  354. }
  355. function send_run_para(){
  356. var run_parameters = []
  357. var msg = {}
  358. $(".dynamic.field .two.fields").each(function(){
  359. var para_name = $(this).find('input[name=shipping_first-name]').val()
  360. var para_value = $(this).find('input[name=shipping_last-name]').val()
  361. run_parameters.push({"label": para_name, "value": para_value})
  362. })
  363. msg["parameter"] = run_parameters
  364. msg = JSON.stringify(msg)
  365. $('#store_run_para').val(msg)
  366. }
  367. function get_name(){
  368. let name1=$("#engine_name .text").text()
  369. let name2=$("#flaver_name .text").text()
  370. $("input#ai_engine_name").val(name1)
  371. $("input#ai_flaver_name").val(name2)
  372. }
  373. $('.ui.create_train_job.green.button').click(function(e) {
  374. get_name()
  375. send_run_para()
  376. validate()
  377. })
  378. </script>