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 29 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  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. margin-bottom: 2rem !important;
  14. }
  15. .width{
  16. width:100% !important;
  17. }
  18. .width80{
  19. width: 80.7% !important;
  20. }
  21. .width85 {
  22. width: 85% !important;
  23. margin-left: 10.5rem !important;
  24. align-items: center;
  25. }
  26. .width35{
  27. width: 35.5% !important;
  28. }
  29. .width48{
  30. width: 48.5% !important;
  31. }
  32. .nowrapx {
  33. white-space: nowrap !important;
  34. }
  35. </style>
  36. {{template "custom/global_mask" .}}
  37. <div class="repository">
  38. {{template "repo/header" .}}
  39. <div class="ui container">
  40. {{template "base/alert" .}}
  41. {{template "custom/alert_cb" .}}
  42. <div class="cloudbrain-type" style="display: none;" data-cloudbrain-type="{{.datasetType}}" data-repo-link="{{.RepoLink}}" data-queue="{{.QueuesDetail}}" data-queue-start="{{.i18n.Tr "repo.wait_count_start"}}" data-queue-end="{{.i18n.Tr "repo.wait_count_end"}}"></div>
  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 id="form_id" class="ui form" action="{{.Link}}" method="post">
  49. {{.CsrfTokenHtml}}
  50. <input type="hidden" name="action" value="update">
  51. <input type="hidden" id="ai_image_name" value="{{.image}}">
  52. <input type="hidden" id="ai_model_version" name="model_version" value="">
  53. <input type="hidden" id="failed_train_url" value="{{$.train_url}}">
  54. <input type="hidden" id="failed_model_name" value="{{$.model_name}}">
  55. <input type="hidden" id="failed_model_version" value="{{$.model_version}}">
  56. <input type="hidden" id="failed_ckpt_name" value="{{$.ckpt_name}}">
  57. <input type="hidden" id="failed_train_url" value="{{$.train_url}}">
  58. <input type="hidden" id="fail_dataset_name" value="{{$.dataset_name}}">
  59. <input type="hidden" id="fail_dataset_uuid" value="{{$.attachment}}">
  60. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:</h4>
  61. <div class="required min_title inline field">
  62. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.compute_resource"}}</label>
  63. <div class="ui blue mini menu compact selectcloudbrain">
  64. <a class="active item" href="{{.RepoLink}}/cloudbrain/inference-job/create">
  65. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16"
  66. height="16">
  67. <path fill="none" d="M0 0h24v24H0z" />
  68. <path
  69. d="M3 2.992C3 2.444 3.445 2 3.993 2h16.014a1 1 0 0 1 .993.992v18.016a.993.993 0 0 1-.993.992H3.993A1 1 0 0 1 3 21.008V2.992zM19 11V4H5v7h14zm0 2H5v7h14v-7zM9 6h6v2H9V6zm0 9h6v2H9v-2z" />
  70. </svg>
  71. CPU/GPU
  72. </a>
  73. <a class="item" href="{{.RepoLink}}/modelarts/inference-job/create">
  74. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16"
  75. height="16">
  76. <path fill="none" d="M0 0h24v24H0z" />
  77. <path
  78. d="M3 2.992C3 2.444 3.445 2 3.993 2h16.014a1 1 0 0 1 .993.992v18.016a.993.993 0 0 1-.993.992H3.993A1 1 0 0 1 3 21.008V2.992zM19 11V4H5v7h14zm0 2H5v7h14v-7zM9 6h6v2H9V6zm0 9h6v2H9v-2z" />
  79. </svg>
  80. Ascend NPU</a>
  81. </div>
  82. </div>
  83. <div class="min_title inline field" style="margin-top:-10px;">
  84. <label class="label-fix-width" style="font-weight: normal;"></label>
  85. {{template "custom/task_wait_count" .}}
  86. <div style="display: flex;align-items: center;margin-left: 156px;margin-top: 0.5rem;">
  87. <i class="ri-error-warning-line" style="color: #f2711c;margin-right: 0.5rem;"></i>
  88. <span style="color: #888;font-size: 12px;">{{.i18n.Tr "cloudbrain.new_infer_gpu_tooltips" "/dataset" "/model" "/result" | Safe}}</span>
  89. </div>
  90. </div>
  91. <div class="required min_title inline field">
  92. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.job_name"}}</label>
  93. <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="36">
  94. <span class="tooltips" style="margin-left:11.5rem;display: block;">{{.i18n.Tr "repo.cloudbrain_jobname_err"}}</span>
  95. </div>
  96. <div class="unite min_title inline field">
  97. <label class="label-fix-width" style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}}</label>
  98. {{if .description}}
  99. <textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="255" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}}>{{.description}}</textarea>
  100. {{else}}
  101. <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>
  102. {{end}}
  103. </div>
  104. <div class="ui divider"></div>
  105. <!-- 模型相关配置 -->
  106. <h4 class="unite title ui header ">{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:</h4>
  107. <div class="required unite inline min_title fields" style="width: 96.8%;">
  108. <div class="required eight wide field">
  109. <label style="font-weight: normal;white-space: nowrap;width: 210px;text-align: right;">{{.i18n.Tr "repo.modelarts.infer_job.select_model"}}</label>
  110. <div class="ui fluid search selection dropdown loading " id="select_model">
  111. <input type="hidden" name="model_name" required>
  112. <div class="text"></div>
  113. <i class="dropdown icon"></i>
  114. <div class="menu" id="model_name">
  115. </div>
  116. </div>
  117. </div>
  118. <div class="three wide field">
  119. <div class="ui fluid search selection dropdown" id="select_model_version">
  120. <input type="hidden" name="train_url" required>
  121. <div class="text"></div>
  122. <i class="dropdown icon"></i>
  123. <div class="menu" id="model_name_version">
  124. </div>
  125. </div>
  126. </div>
  127. <div class="five wide field">
  128. <div class="ui fluid search selection dropdown" id="select_model_checkpoint">
  129. <input type="hidden" name="ckpt_name" required>
  130. <div class="text"></div>
  131. <i class="dropdown icon"></i>
  132. <div class="menu" id="model_checkpoint">
  133. </div>
  134. </div>
  135. </div>
  136. <span >
  137. <i class="question circle icon" data-content="{{.i18n.Tr "cloudbrain.model_file_postfix_rule"}}" data-position="top center" data-variation="inverted mini"></i>
  138. </span>
  139. </div>
  140. <!-- AI引擎 -->
  141. <div id="images-new-cb">
  142. </div>
  143. <!-- 代码分支 -->
  144. <div class="required min_title inline field">
  145. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.code_version"}}</label>
  146. <select class="ui dropdown width48" id="code_version" name="branch_name">
  147. {{if .branch_name}}
  148. <option name="branch_name" value="{{.branch_name}}">{{.branch_name}}</option>
  149. {{range $k, $v :=.Branches}}
  150. {{ if ne $v $.branch_name }}
  151. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  152. {{end}}
  153. {{end}}
  154. {{else}}
  155. <option name="branch_name" value="{{.branchName}}">{{.branchName}}</option>
  156. {{range $k, $v :=.Branches}}
  157. {{ if ne $v $.branchName }}
  158. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  159. {{end}}
  160. {{end}}
  161. {{end}}
  162. </select>
  163. </div>
  164. <!-- GPU 卡的类型 -->
  165. <!--<div class="required min_title inline field">
  166. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.gpu_type"}}</label>
  167. <select id="cloudbrain_gpu_type" class="ui search width48 dropdown gpu-type" placeholder="选择GPU类型"
  168. style='width:385px' name="gpu_type">
  169. {{if .gpu_type}}
  170. {{range .inference_gpu_types}}
  171. {{if eq $.gpu_type .Queue}}
  172. <option value="{{.Queue}}">{{.Value}}</option>
  173. {{end}}
  174. {{end}}
  175. {{range .inference_gpu_types}}
  176. {{if ne $.gpu_type .Queue}}
  177. <option value="{{.Queue}}">{{.Value}}</option>
  178. {{end}}
  179. {{end}}
  180. {{else}}
  181. {{range .inference_gpu_types}}
  182. <option value="{{.Queue}}">{{.Value}}</option>
  183. {{end}}
  184. {{end}}
  185. </select>
  186. </div>-->
  187. <!-- 数据集-->
  188. <div id="select-multi-dataset">
  189. </div>
  190. <span class="tooltips" style="margin-left: 11.5rem;margin-bottom: 1rem;"></span>
  191. <div class="inline min_title field required">
  192. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label>
  193. {{if .boot_file}}
  194. <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="{{.boot_file}}" tabindex="3" autofocus required maxlength="255" >
  195. {{else}}
  196. <input style="width: 48.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255" >
  197. {{end}}
  198. <span >
  199. <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>
  200. </span>
  201. <a href="https://git.openi.org.cn/OpenIOSSG/MNIST_PytorchExample_GPU/src/branch/master/inference.py" target="_blank">{{.i18n.Tr "cloudbrain.view_sample"}}</a>
  202. </div>
  203. <!-- 运行参数 -->
  204. <div class="inline min_title field">
  205. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.run_parameter"}}</label>
  206. <span id="add_run_para" style="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>
  207. <input id="store_run_para" type="hidden" name="run_para_list">
  208. <div class="dynamic field" style="margin-top: 1rem;" data-params="{{.run_para_list}}">
  209. </div>
  210. </div>
  211. <div class="required field " style="display: none;">
  212. <label style="font-weight: normal;">{{.i18n.Tr "repo.modelarts.train_job.resource_pool"}}</label>
  213. <select class="ui dropdown" id="trainjob_resource_pool" style='width:385px' name="pool_id">
  214. {{range .resource_pools}}
  215. <option value="{{.ID}}">{{.Value}}</option>
  216. {{end}}
  217. </select>
  218. </div>
  219. <!-- 规格 -->
  220. <!--<div class="required min_title inline field">
  221. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.resource_specification"}}</label>
  222. <select id="cloudbrain_resource_spec" class="ui search dropdown width80" placeholder="选择资源规格" name="resource_spec_id">
  223. {{if .resource_spec_id}}
  224. {{range .inference_resource_specs}}
  225. {{if eq $.resource_spec_id .Id}}
  226. <option value="{{.Id}}">{{$.i18n.Tr "cloudbrain.gpu_num"}}:{{.GpuNum}},{{$.i18n.Tr "cloudbrain.cpu_num"}}:{{.CpuNum}},{{$.i18n.Tr "cloudbrain.memory"}}(MB):{{$.i18n.Tr "cloudbrain.shared_memory"}}(MB):{{.ShareMemMiB}}</option>
  227. {{end}}
  228. {{end}}
  229. {{range .inference_resource_specs}}
  230. {{if ne $.resource_spec_id .Id}}
  231. <option value="{{.Id}}">{{$.i18n.Tr "cloudbrain.gpu_num"}}:{{.GpuNum}},{{$.i18n.Tr "cloudbrain.cpu_num"}}:{{.CpuNum}},{{$.i18n.Tr "cloudbrain.memory"}}(MB):{{$.i18n.Tr "cloudbrain.shared_memory"}}(MB):{{.ShareMemMiB}}</option>
  232. {{end}}
  233. {{end}}
  234. {{else}}
  235. {{range .inference_resource_specs}}
  236. <option name="resource_spec_id" value="{{.Id}}">
  237. {{$.i18n.Tr "cloudbrain.gpu_num"}}:{{.GpuNum}},{{$.i18n.Tr "cloudbrain.cpu_num"}}:{{.CpuNum}},{{$.i18n.Tr "cloudbrain.memory"}}(MB):{{$.i18n.Tr "cloudbrain.shared_memory"}}(MB):{{.ShareMemMiB}}</option>
  238. {{end}}
  239. {{end}}
  240. </select>
  241. </div>-->
  242. <div class="required min_title inline field">
  243. <label class="label-fix-width" style="font-weight: normal;">{{.i18n.Tr "cloudbrain.resource_specification"}}</label>
  244. <select id="__specs__" class="ui search dropdown width48" placeholder="{{.i18n.Tr "cloudbrain.select_specification"}}" ovalue="{{.spec_id}}" name="spec_id" {{if .CloudBrainPaySwitch}}blance="{{.PointAccount.Balance}}"{{end}}>
  245. </select>
  246. <span><i class="question circle icon link"></i></span>
  247. <a href="{{AppSubUrl}}/resource_desc" target="_blank">{{.i18n.Tr "custom.resource_description"}}</a>
  248. {{if .CloudBrainPaySwitch}}
  249. <div class="cloudbrain_resource_spec_blance_tip width48" style="padding:0 5px;margin:6px 0;margin-left:155px;font-size:12px;">
  250. <span>{{$.i18n.Tr "points.balance_of_points"}}<span style="color:red;margin: 0 3px">{{.PointAccount.Balance}}</span>{{$.i18n.Tr "points.points"}}</span><span>{{$.i18n.Tr "points.expected_time"}}<span style="color:red;margin: 0 3px" class="can-use-time"></span>{{$.i18n.Tr "points.hours"}}</span>
  251. <span style="float:right;">
  252. <i class="question circle icon link" data-position="right center" data-variation="mini"></i>
  253. <a href="{{AppSubUrl}}/reward/point/rule" target="_blank">{{$.i18n.Tr "points.points_acquisition_instructions"}}</a>
  254. </span>
  255. </div>
  256. {{end}}
  257. </div>
  258. <!-- 表单操作 -->
  259. <div class="inline min_title field">
  260. <label class="label-fix-width" style="font-weight: normal;"></label>
  261. <button class="ui create_train_job green button">
  262. {{.i18n.Tr "repo.cloudbrain.new"}}
  263. </button>
  264. <a class="ui button" href="{{.RepoLink}}/modelarts/inference-job">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  265. </div>
  266. <!-- 模态框 -->
  267. </form>
  268. </div>
  269. </div>
  270. </div>
  271. {{template "base/footer" .}}
  272. <script src="{{StaticUrlPrefix}}/js/specsuse.js?v={{MD5 AppVer}}" type="text/javascript"></script>
  273. <script>
  274. let form = document.getElementById('form_id');
  275. let createFlag = false
  276. form.onsubmit = function (e) {
  277. if(createFlag) return false
  278. createFlag = true
  279. }
  280. const RepoLink = {{.RepoLink}}
  281. let nameMap,nameList
  282. // 获取模型列表和模型名称对应的模型版本
  283. $(document).ready(function(){
  284. modelVersion()
  285. modelCkpt()
  286. $.get(`${RepoLink}/modelmanage/query_model_for_predict?type=0`, (data) => {
  287. nameMap = data.nameMap
  288. nameList = data.nameList
  289. let faildModelName = document.getElementById('failed_model_name').value
  290. let html = ''
  291. nameList.forEach(element => {
  292. html += `<div class="item" data-value=${element}>${element}</div>`
  293. });
  294. if(nameList.length!==0){
  295. $('#model_name').append(html)
  296. if(faildModelName){
  297. $("#select_model").dropdown('set text',faildModelName)
  298. $("#select_model").dropdown('set value',faildModelName)
  299. }else{
  300. $("#select_model").dropdown('set text',nameList[0])
  301. $("#select_model").dropdown('set value',nameList[0],nameList[0])
  302. }
  303. }
  304. $('#select_model').removeClass("loading")
  305. })
  306. })
  307. // 根据选中的模型名称获取相应的模型版本
  308. function modelVersion(){
  309. let faildModelVersion = $('#failed_model_version').val()
  310. let faildTrainUrl = $('#failed_train_url').val()
  311. $('#select_model').dropdown({
  312. onChange: function(value, text, $selectedItem) {
  313. $("#select_model_version").addClass("loading")
  314. $('#model_name_version').empty()
  315. let html = ''
  316. nameMap[value].forEach(element => {
  317. html += `<div class="item" data-label="${element.label}" data-id="${element.id}" data-value="${element.path}">${element.version}</div>`
  318. });
  319. $('#model_name_version').append(html)
  320. $("#select_model_version").removeClass("loading")
  321. const initVersionText = $('#model_name_version div.item:first-child').text()
  322. const initVersionValue = $('#model_name_version div.item:first-child').data('value')
  323. if(faildModelVersion&&faildTrainUrl){
  324. $("#select_model_version").dropdown('set text',faildModelVersion)
  325. $("#select_model_version").dropdown('set value',faildTrainUrl,faildModelVersion,$('#model_name_version div.item:first-child'))
  326. }else{
  327. $("#select_model_version").dropdown('set text',initVersionText)
  328. $("#select_model_version").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child'))
  329. }
  330. }
  331. })
  332. }
  333. // 根据选中的模型版本获取相应的模型权重文件
  334. function modelCkpt(){
  335. let faildCkptName = $('#failed_ckpt_name').val()
  336. $('#select_model_version').dropdown({
  337. onChange: function(value, text, $selectedItem) {
  338. const dataID = $selectedItem[0].getAttribute("data-id")
  339. const label = $selectedItem[0].getAttribute("data-label")
  340. $("#select_model_checkpoint").addClass("loading")
  341. $("#model_checkpoint").empty()
  342. let html = ''
  343. loadCheckpointList(dataID).then((res)=>{
  344. res.forEach(element => {
  345. const ckptSuffix = element.FileName.split(".")
  346. const loadCheckpointFile = ['ckpt','pb','h5','json','pkl','pth','t7','pdparams','onnx','pbtxt','keras','mlmodel','cfg','pt']
  347. if(!element.IsDir && loadCheckpointFile.includes(ckptSuffix[ckptSuffix.length-1])){
  348. html += `<div class="item" data-value=${element.FileName}>${element.FileName}</div>`
  349. }
  350. })
  351. $('#model_checkpoint').append(html)
  352. $("#select_model_checkpoint").removeClass("loading")
  353. const initVersionText = $('#model_checkpoint div.item:first-child').text()
  354. const initVersionValue = $('#model_checkpoint div.item:first-child').data('value')
  355. if(faildCkptName){
  356. $("#select_model_checkpoint").dropdown('set text',faildCkptName)
  357. $("#select_model_checkpoint").dropdown('set value',faildCkptName,faildCkptName,$('#model_name_version div.item:first-child'))
  358. }else{
  359. $("#select_model_checkpoint").dropdown('set text',initVersionText)
  360. $("#select_model_checkpoint").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child'))
  361. }
  362. })
  363. $("input#ai_model_version").val(text)
  364. $("input#ai_model_label").val(label)
  365. }
  366. })
  367. }
  368. function loadCheckpointList(value){
  369. return new Promise((resolve,reject)=>{
  370. $.get(`${RepoLink}/modelmanage/query_modelfile_for_predict`,{id:value}, (data) => {
  371. resolve(data)
  372. })
  373. })
  374. }
  375. $('.question.circle.icon').hover(function(){
  376. $(this).popup('show')
  377. });
  378. $(document).ready(function(){
  379. let params = $('.dynamic.field').data('params')
  380. params&&params.parameter.forEach((item,index)=>{
  381. Add_parameter(index,flag=true,item)
  382. })
  383. })
  384. // 参数增加、删除、修改、保存
  385. function Add_parameter(i,flag=false,paramsObject={}) {
  386. let value = ''
  387. value += `<div class="two fields width85" id= "para${i}">`
  388. value += '<div class="field">'
  389. let placeholder_value='{{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}'
  390. let placeholder_name='{{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}'
  391. if(flag){
  392. value +=`<input type="text" class="shipping_first-name" value="${paramsObject.label}">`
  393. }else{
  394. value +='<input type="text" class="shipping_first-name" required placeholder="' + placeholder_name+ '">'
  395. }
  396. value += '</div>'
  397. value += '<div class="field">'
  398. if(flag){
  399. value +=`<input type="text" class="shipping_last-name" value="${paramsObject.value}">`
  400. }else{
  401. value +='<input type="text" class="shipping_last-name" required placeholder="' + placeholder_value+ '">'
  402. }
  403. value += '</div>'
  404. value += '<span><i class="trash icon"></i></span>'
  405. value += '</div>'
  406. $(".dynamic.field").append(value)
  407. }
  408. $('#add_run_para').click(function () {
  409. var len = $(".dynamic.field .two.fields").length
  410. Add_parameter(len)
  411. });
  412. $(".dynamic.field").on("click", ".trash.icon", function () {
  413. var index = $(this).parent().parent().index()
  414. $(this).parent().parent().remove()
  415. var len = $(".dynamic.field .two.fields").length
  416. $(".dynamic.field .two.fields").each(function () {
  417. var cur_index = $(this).index()
  418. $(this).attr('id', 'para' + cur_index)
  419. })
  420. });
  421. function send_run_para() {
  422. var run_parameters = []
  423. var msg = {}
  424. $(".dynamic.field .two.fields").each(function () {
  425. var para_name = $(this).find('input.shipping_first-name').val()
  426. var para_value = $(this).find('input.shipping_last-name').val()
  427. run_parameters.push({ "label": para_name, "value": para_value })
  428. })
  429. msg["parameter"] = run_parameters
  430. msg = JSON.stringify(msg)
  431. $('#store_run_para').val(msg)
  432. }
  433. var isValidate = false;
  434. function validate(){
  435. $('.ui.form')
  436. .form({
  437. on: 'blur',
  438. fields: {
  439. boot_file: {
  440. identifier : 'boot_file',
  441. rules: [
  442. {
  443. type: 'regExp[/.+\.py$/g]',
  444. }
  445. ]
  446. },
  447. display_job_name:{
  448. identifier : 'display_job_name',
  449. rules: [
  450. {
  451. type: 'regExp[/^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$/]',
  452. }
  453. ]
  454. },
  455. attachment:{
  456. identifier : 'attachment',
  457. rules: [
  458. {
  459. type: 'empty',
  460. }
  461. ]
  462. },
  463. model_name:{
  464. identifier : 'model_name',
  465. rules: [
  466. {
  467. type: 'empty',
  468. }
  469. ]
  470. },
  471. train_url:{
  472. identifier : 'train_url',
  473. rules: [
  474. {
  475. type: 'empty',
  476. }
  477. ]
  478. },
  479. ckpt_name:{
  480. identifier : 'ckpt_name',
  481. rules: [
  482. {
  483. type: 'empty',
  484. }
  485. ]
  486. },
  487. spec_id: {
  488. identifier: 'spec_id',
  489. rules: [{ type: 'empty' }]
  490. }
  491. },
  492. onSuccess: function(){
  493. document.getElementById("mask").style.display = "block"
  494. isValidate = true;
  495. },
  496. onFailure: function(e){
  497. isValidate = false;
  498. return false;
  499. }
  500. })
  501. }
  502. document.onreadystatechange = function() {
  503. if (document.readyState === "complete") {
  504. document.getElementById("mask").style.display = "none"
  505. }
  506. }
  507. validate();
  508. $('.ui.create_train_job.green.button').click(function(e) {
  509. send_run_para();
  510. validate();
  511. })
  512. ;(function() {
  513. var SPECS = {{ .inference_specs }};
  514. var showPoint = {{ .CloudBrainPaySwitch }};
  515. window.renderSpecsSelect($('#__specs__'), SPECS, showPoint, {
  516. gpu_memory: {{$.i18n.Tr "cloudbrain.gpu_memory"}},
  517. free: {{$.i18n.Tr "cloudbrain.free"}},
  518. point_hr: {{$.i18n.Tr "cloudbrain.point_hr"}},
  519. memory: {{$.i18n.Tr "cloudbrain.memory"}},
  520. shared_memory: {{$.i18n.Tr "cloudbrain.shared_memory"}},
  521. });
  522. })();
  523. </script>