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
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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  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. .width80{
  17. width: 80.7% !important;
  18. }
  19. .width84{
  20. width: 84% !important;
  21. margin-left: 5.1rem !important;
  22. }
  23. .width35{
  24. width: 35.5% !important;
  25. }
  26. .nowrap {
  27. white-space: nowrap !important;
  28. }
  29. </style>
  30. <div id="mask">
  31. <div id="loadingPage">
  32. <div class="rect1"></div>
  33. <div class="rect2"></div>
  34. <div class="rect3"></div>
  35. <div class="rect4"></div>
  36. <div class="rect5"></div>
  37. </div>
  38. </div>
  39. <div class="repository">
  40. {{template "repo/header" .}}
  41. <div class="ui container">
  42. {{template "base/alert" .}}
  43. <h4 class="ui top attached header">
  44. {{.i18n.Tr "repo.modelarts.train_job.new"}}
  45. </h4>
  46. <div class="ui attached segment">
  47. <!-- equal width -->
  48. <form class="ui form" action="{{.Link}}" method="post">
  49. {{.CsrfTokenHtml}}
  50. <input type="hidden" name="action" value="update">
  51. <input type="hidden" id="ai_engine_name" name="engine_names" value="">
  52. <input type="hidden" id="ai_flaver_name" name="flaver_names" value="">
  53. <input type="hidden" id="ai_model_version" name="model_version" value="">
  54. <input type="hidden" id="ai_model_label" name="label_names" value="">
  55. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4>
  56. <div class="required unite min_title inline field">
  57. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.job_name"}}</label>
  58. <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="36">
  59. <span class="tooltips" style="display: block;">请输入只包含大小写字母、数字、_和-,最长36个字符。</span>
  60. </div>
  61. <div class="unite min_title inline field">
  62. <label style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label>&nbsp;&nbsp;
  63. <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>
  64. </div>
  65. <div class="ui divider"></div>
  66. <!-- 模型相关配置 -->
  67. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:</h4>
  68. <div class="required unite inline min_title fields" style="width: 91.8%;">
  69. <div class="required eight wide field">
  70. <label style="font-weight: normal;white-space: nowrap;">{{.i18n.Tr "repo.modelarts.infer_job.select_model"}}</label>&nbsp;&nbsp;
  71. <div class="ui fluid search selection dropdown loading" id="select_model">
  72. {{if $.ckpt_name}}
  73. <input type="hidden" name="model_name" value="{{$.model_name}}" required>
  74. <div class="text">{{$.model_name}}</div>
  75. {{else}}
  76. <input type="hidden" name="model_name" required>
  77. <div class="text"></div>
  78. {{end}}
  79. <i class="dropdown icon"></i>
  80. <div class="menu" id="model_name">
  81. </div>
  82. </div>
  83. </div>
  84. <div class="three wide field">
  85. <div class="ui fluid search selection dropdown" id="select_model_version">
  86. {{if $.ckpt_name}}
  87. <input type="hidden" name="train_url" value="{{$.model_version}}" required>
  88. <div class="text">{{$.model_version}}</div>
  89. {{else}}
  90. <input type="hidden" name="train_url" required>
  91. <div class="text"></div>
  92. {{end}}
  93. <i class="dropdown icon"></i>
  94. <div class="menu" id="model_name_version">
  95. </div>
  96. </div>
  97. </div>
  98. <div class="five wide field">
  99. <div class="ui fluid search selection dropdown" id="select_model_checkpoint">
  100. {{if $.ckpt_name}}
  101. <input type="hidden" name="ckpt_name" value="{{$.ckpt_name}}" required>
  102. <div class="text">{{$.ckpt_name}}</div>
  103. {{else}}
  104. <input type="hidden" name="ckpt_name" required>
  105. <div class="text"></div>
  106. {{end}}
  107. <i class="dropdown icon"></i>
  108. <div class="menu" id="model_checkpoint">
  109. </div>
  110. </div>
  111. </div>
  112. <span >
  113. <i class="question circle icon" data-content="模型文件位置存储在环境变量ckpt_path中。" data-position="top center" data-variation="inverted mini"></i>
  114. </span>
  115. </div>
  116. <!-- AI引擎 -->
  117. <div class="required unite inline min_title fields" style="width: 90%;">
  118. <div class="required eight wide field">
  119. <label style="font-weight: normal;white-space: nowrap;">{{.i18n.Tr "repo.modelarts.train_job.AI_driver"}}</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  120. <select class="ui fluid selection search dropdown" id="trainjob_engines">
  121. {{range .engines}}
  122. <option value="{{.Value}}">{{.Value}}</option>
  123. {{end}}
  124. </select>
  125. </div>
  126. <div class="eight wide field" id="engine_name">
  127. <select class="ui fluid selection dropdown nowrap" id="trainjob_engine_versions" name="engine_id" style="white-space: nowrap;">
  128. {{range .engine_versions}}
  129. <option name="engine_id" value="{{.ID}}">{{.Value}}</option>
  130. {{end}}
  131. </select>
  132. </div>
  133. </div>
  134. <!-- 代码分支 -->
  135. <div class="required unite min_title inline field">
  136. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.code_version"}}</label>&nbsp;
  137. <select class="ui dropdown width35" id="code_version" name="branch_name">
  138. {{if .branch_name}}
  139. <option name="branch_name" value="{{.branch_name}}">{{.branch_name}}</option>
  140. {{range $k, $v :=.Branches}}
  141. {{ if ne $v $.branch_name }}
  142. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  143. {{end}}
  144. {{end}}
  145. {{else}}
  146. <option name="branch_name" value="{{.branchName}}">{{.branchName}}</option>
  147. {{range $k, $v :=.Branches}}
  148. {{ if ne $v $.branchName }}
  149. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  150. {{end}}
  151. {{end}}
  152. {{end}}
  153. </select>
  154. </div>
  155. <!-- 数据集 -->
  156. <div class="required unite min_title inline field">
  157. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.dataset"}}</label>&nbsp;&nbsp;&nbsp;&nbsp;
  158. <select class="ui dropdown width35" id="trainjob_datasets" name="attachment" placeholder="选择数据集" required>
  159. {{if $.uuid}}
  160. <option name="attachment" value="{{$.uuid}}">{{$.datasetName}}</option>
  161. {{end}}
  162. {{range .attachments}}
  163. <option value="">选择数据集</option>
  164. <option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option>
  165. {{end}}
  166. </select>
  167. <span>
  168. <i class="question circle icon" data-content="数据集位置存储在环境变量data_url中。" data-position="top center" data-variation="inverted mini"></i>
  169. </span>
  170. <span class="tooltips" style="display: block;">数据集位置存储在环境变量data_url中,推理输出路径存储在环境变量result_url中。</span>
  171. </div>
  172. <!-- 启动文件 -->
  173. <div class="inline unite min_title field required">
  174. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label>&nbsp;
  175. {{if .bootFile}}
  176. <input style="width: 35.5%;" name="boot_file" id="trainjob_boot_file" value="{{.bootFile}}" tabindex="3" autofocus required maxlength="254" >
  177. {{else}}
  178. <input style="width: 35.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="254" >
  179. {{end}}
  180. <span >
  181. <i class="question circle icon" data-content={{.i18n.Tr "repo.modelarts.train_job.boot_file_helper"}} data-position="top center" data-variation="inverted mini"></i>
  182. </span>
  183. <a href="https://git.openi.org.cn/OpenIOSSG/MINIST_Example" target="_blank">查看样例</a>
  184. </div>
  185. <!-- 运行参数 -->
  186. <div class="inline unite min_title field">
  187. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label>&nbsp;&nbsp;
  188. <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>
  189. <input id="store_run_para" type="hidden" name="run_para_list">
  190. <div class="dynamic field" style="margin-top: 1rem;">
  191. {{if ne 0 (len .params)}}
  192. {{range $k ,$v := .params}}
  193. <div class="two fields width84" id="para{{$k}}">
  194. <div class="field">
  195. <input type="text" name="shipping_first-name" value={{$v.Label}} required>
  196. </div>
  197. <div class="field">
  198. <input type="text" name="shipping_last-name" value={{$v.Value}} required>
  199. </div>
  200. <span>
  201. <i class="trash icon"></i>
  202. </span>
  203. </div>
  204. {{end}}
  205. {{end}}
  206. </div>
  207. </div>
  208. <div class="required field " style="display: none;">
  209. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.resource_pool"}}</label>
  210. <select class="ui dropdown" id="trainjob_resource_pool" style='width:385px' name="pool_id">
  211. {{range .resource_pools}}
  212. <option value="{{.ID}}">{{.Value}}</option>
  213. {{end}}
  214. </select>
  215. </div>
  216. <!-- 规格 -->
  217. <div class="required unite min_title inline field" id="flaver_name">
  218. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.standard"}}</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  219. <select class="ui dropdown width80" id="trainjob-flavor" name="flavor">
  220. {{range .flavor_infos}}
  221. <option name="flavor" value="{{.Code}}">{{.Value}}</option>
  222. {{end}}
  223. </select>
  224. </div>
  225. <!-- 计算节点 -->
  226. <div class="inline required unite min_title field">
  227. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.amount_of_compute_node"}}</label>
  228. <div class="ui labeled input" style="width: 5%;">
  229. <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>
  230. </div>
  231. </div>
  232. <!-- 表单操作 -->
  233. <div class="inline unite min_title field">
  234. <button class="ui create_train_job green button">
  235. {{.i18n.Tr "repo.cloudbrain.new"}}
  236. </button>
  237. <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  238. </div>
  239. <!-- 模态框 -->
  240. </form>
  241. </div>
  242. </div>
  243. </div>
  244. {{template "base/footer" .}}
  245. <script>
  246. const RepoLink = {{.RepoLink}}
  247. const url_href = window.location.pathname.split('create')[0]
  248. let nameMap,nameList
  249. $(".ui.button").attr('href',url_href)
  250. // 获取模型列表和模型名称对应的模型版本
  251. $.get(`${RepoLink}/modelmanage/query_model_for_predict`, (data) => {
  252. nameMap = data.nameMap
  253. nameList = data.nameList
  254. let html = ''
  255. nameList.forEach(element => {
  256. html += `<div class="item" data-value=${element}>${element}</div>`
  257. });
  258. const initModelVersion = nameMap[nameList[0]][0]
  259. const initTrainTaskInfo = JSON.parse(initModelVersion.TrainTaskInfo)
  260. $('#model_name').append(html)
  261. $('#select_model').removeClass("loading")
  262. $("#select_model").dropdown('set text',nameList[0])
  263. $("#select_model").dropdown('set value',nameList[0],nameList[0])
  264. })
  265. // 根据选中的模型名称获取相应的模型版本
  266. $(function(){
  267. $('#select_model').dropdown({
  268. onChange: function(value, text, $selectedItem) {
  269. $("#select_model_version").addClass("loading")
  270. $('#model_name_version').empty()
  271. let html = ''
  272. nameMap[value].forEach(element => {
  273. let {TrainTaskInfo} = element
  274. TrainTaskInfo = JSON.parse(TrainTaskInfo)
  275. html += `<div class="item" data-label="${element.Label}" data-id="${element.ID}" data-value="${TrainTaskInfo.TrainUrl}">${element.Version}</div>`
  276. });
  277. $('#model_name_version').append(html)
  278. $("#select_model_version").removeClass("loading")
  279. const initVersionText = $('#model_name_version div.item:first-child').text()
  280. const initVersionValue = $('#model_name_version div.item:first-child').data('value')
  281. $("#select_model_version").dropdown('set text',initVersionText)
  282. $("#select_model_version").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child'))
  283. }
  284. })
  285. })
  286. // 根据选中的模型版本获取相应的模型权重文件
  287. $(function(){
  288. $('#select_model_version').dropdown({
  289. onChange: function(value, text, $selectedItem) {
  290. const dataID = $selectedItem[0].getAttribute("data-id")
  291. const label = $selectedItem[0].getAttribute("data-label")
  292. $("#select_model_checkpoint").addClass("loading")
  293. $("#model_checkpoint").empty()
  294. let html = ''
  295. loadCheckpointList(dataID).then((res)=>{
  296. res.forEach(element => {
  297. const ckptSuffix = element.FileName.split(".")
  298. if(!element.IsDir && ckptSuffix[ckptSuffix.length-1]==='ckpt'){
  299. html += `<div class="item" data-value=${element.FileName}>${element.FileName}</div>`
  300. }
  301. })
  302. $('#model_checkpoint').append(html)
  303. $("#select_model_checkpoint").removeClass("loading")
  304. const initVersionText = $('#model_checkpoint div.item:last-child').text()
  305. const initVersionValue = $('#model_checkpoint div.item:last-child').data('value')
  306. $("#select_model_checkpoint").dropdown('set text',initVersionText)
  307. $("#select_model_checkpoint").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child'))
  308. })
  309. $("input#ai_model_version").val(text)
  310. $("input#ai_model_label").val(label)
  311. }
  312. })
  313. })
  314. function loadCheckpointList(value){
  315. return new Promise((resolve,reject)=>{
  316. $.get(`${RepoLink}/modelmanage/query_modelfile_for_predict`,{ID:value}, (data) => {
  317. resolve(data)
  318. })
  319. })
  320. }
  321. $('.question.circle.icon').hover(function(){
  322. $(this).popup('show')
  323. });
  324. // 参数增加、删除、修改、保存
  325. function Add_parameter(i){
  326. value = '<div class="two fields width84" id= "para'+ i +'">' +
  327. '<div class="field">' +
  328. '<input type="text" name="shipping_first-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}> ' +
  329. '</div> ' +
  330. '<div class="field"> ' +
  331. '<input type="text" name="shipping_last-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}>' +
  332. '</div>'+
  333. '<span>' +
  334. '<i class="trash icon">' +
  335. '</i>' +
  336. '</span>' +
  337. '</div>'
  338. $(".dynamic.field").append(value)
  339. }
  340. $('#add_run_para').click(function(){
  341. var len = $(".dynamic.field .two.fields").length
  342. Add_parameter(len)
  343. });
  344. $(".dynamic.field").on("click",".trash.icon", function() {
  345. var index = $(this).parent().parent().index()
  346. $(this).parent().parent().remove()
  347. var len = $(".dynamic.field .two.fields").length
  348. $(".dynamic.field .two.fields").each(function(){
  349. var cur_index = $(this).index()
  350. $(this).attr('id', 'para' + cur_index)
  351. })
  352. });
  353. function send_run_para(){
  354. var run_parameters = []
  355. var msg = {}
  356. $(".dynamic.field .two.fields").each(function(){
  357. var para_name = $(this).find('input[name=shipping_first-name]').val()
  358. var para_value = $(this).find('input[name=shipping_last-name]').val()
  359. run_parameters.push({"label": para_name, "value": para_value})
  360. })
  361. msg["parameter"] = run_parameters
  362. msg = JSON.stringify(msg)
  363. $('#store_run_para').val(msg)
  364. }
  365. function get_name(){
  366. let name1=$("#engine_name .text").text()
  367. let name2=$("#flaver_name .text").text()
  368. $("input#ai_engine_name").val(name1)
  369. $("input#ai_flaver_name").val(name2)
  370. }
  371. function validate(){
  372. $('.ui.form')
  373. .form({
  374. on: 'blur',
  375. fields: {
  376. boot_file: {
  377. identifier : 'boot_file',
  378. rules: [
  379. {
  380. type: 'regExp[/.+\.py$/g]',
  381. }
  382. ]
  383. },
  384. job_name:{
  385. identifier : 'job_name',
  386. rules: [
  387. {
  388. type: 'regExp[/^[a-zA-Z0-9-_]{1,36}$/]',
  389. }
  390. ]
  391. },
  392. attachment:{
  393. identifier : 'attachment',
  394. rules: [
  395. {
  396. type: 'empty',
  397. }
  398. ]
  399. },
  400. model_name:{
  401. identifier : 'model_name',
  402. rules: [
  403. {
  404. type: 'empty',
  405. }
  406. ]
  407. },
  408. train_url:{
  409. identifier : 'train_url',
  410. rules: [
  411. {
  412. type: 'empty',
  413. }
  414. ]
  415. },
  416. ckpt_name:{
  417. identifier : 'ckpt_name',
  418. rules: [
  419. {
  420. type: 'empty',
  421. }
  422. ]
  423. }
  424. },
  425. onSuccess: function(){
  426. document.getElementById("mask").style.display = "block"
  427. },
  428. onFailure: function(e){
  429. return false;
  430. }
  431. })
  432. }
  433. document.onreadystatechange = function() {
  434. if (document.readyState === "complete") {
  435. document.getElementById("mask").style.display = "none"
  436. }
  437. }
  438. $('.ui.create_train_job.green.button').click(function(e) {
  439. send_run_para()
  440. get_name()
  441. validate()
  442. })
  443. </script>