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