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

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. {{template "base/head" .}}
  2. <style>
  3. /* 遮罩层css效果图 */
  4. .inline.required.field.cloudbrain_benchmark {
  5. display: none;
  6. }
  7. .inline.required.field.cloudbrain_snn4imagenet {
  8. display: none;
  9. }
  10. .inline.required.field.cloudbrain_brainscore {
  11. display: none;
  12. }
  13. </style>
  14. {{template "custom/global_mask" .}}
  15. <div class="repository">
  16. {{template "repo/header" .}}
  17. <div class="repository new repo ui middle very relaxed page grid">
  18. <div class="column">
  19. <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>
  20. {{if eq .NotStopTaskCount 0}}
  21. {{template "base/alert" .}}
  22. {{end}}
  23. <div class="ui negative message" id="messageInfo" style="display:none;">
  24. <p></p>
  25. </div>
  26. {{template "custom/alert_cb" .}}
  27. <form id="form_id" class="ui form" action="{{.Link}}" method="post">
  28. {{.CsrfTokenHtml}}
  29. <input type="hidden" name='isBranches' value="{{.Branches}}">
  30. <input type="hidden" name="type" value="0">
  31. <h3 class="ui top attached header">
  32. {{.i18n.Tr "repo.cloudbrain.new"}}
  33. </h3>
  34. <div class="ui attached segment">
  35. <div class="required inline field">
  36. <label>{{.i18n.Tr "cloudbrain.resource_cluster"}}</label>
  37. <div class="ui blue mini menu compact selectcloudbrain">
  38. <a class="item" href="{{.RepoLink}}/cloudbrain/create">
  39. <svg class="svg" sxmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-2.29-2.333A17.9 17.9 0 0 1 8.027 13H4.062a8.008 8.008 0 0 0 5.648 6.667zM10.03 13c.151 2.439.848 4.73 1.97 6.752A15.905 15.905 0 0 0 13.97 13h-3.94zm9.908 0h-3.965a17.9 17.9 0 0 1-1.683 6.667A8.008 8.008 0 0 0 19.938 13zM4.062 11h3.965A17.9 17.9 0 0 1 9.71 4.333 8.008 8.008 0 0 0 4.062 11zm5.969 0h3.938A15.905 15.905 0 0 0 12 4.248 15.905 15.905 0 0 0 10.03 11zm4.259-6.667A17.9 17.9 0 0 1 15.973 11h3.965a8.008 8.008 0 0 0-5.648-6.667z"></path></svg>
  40. {{.i18n.Tr "cloudbrain.resource_cluster_openi"}}
  41. </a>
  42. <a class="active item" href="{{.RepoLink}}/grampus/notebook/create?type=0">
  43. <svg class="svg" sxmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-2.29-2.333A17.9 17.9 0 0 1 8.027 13H4.062a8.008 8.008 0 0 0 5.648 6.667zM10.03 13c.151 2.439.848 4.73 1.97 6.752A15.905 15.905 0 0 0 13.97 13h-3.94zm9.908 0h-3.965a17.9 17.9 0 0 1-1.683 6.667A8.008 8.008 0 0 0 19.938 13zM4.062 11h3.965A17.9 17.9 0 0 1 9.71 4.333 8.008 8.008 0 0 0 4.062 11zm5.969 0h3.938A15.905 15.905 0 0 0 12 4.248 15.905 15.905 0 0 0 10.03 11zm4.259-6.667A17.9 17.9 0 0 1 15.973 11h3.965a8.008 8.008 0 0 0-5.648-6.667z"></path></svg>
  44. {{.i18n.Tr "cloudbrain.resource_cluster_c2net"}}(Beta)
  45. </a>
  46. </div>
  47. </div>
  48. <div class="inline required field">
  49. <label>{{.i18n.Tr "cloudbrain.compute_resource"}}</label>
  50. <div class="ui blue small menu compact selectcloudbrain">
  51. <a class="active item" href="{{.RepoLink}}/grampus/notebook/create?type=0">
  52. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16"
  53. height="16">
  54. <path fill="none" d="M0 0h24v24H0z" />
  55. <path
  56. 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" />
  57. </svg>
  58. CPU/GPU
  59. </a>
  60. <a class="item" href="{{.RepoLink}}/grampus/notebook/create?type=1">
  61. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16"
  62. height="16">
  63. <path fill="none" d="M0 0h24v24H0z" />
  64. <path
  65. 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" />
  66. </svg>
  67. Ascend NPU</a>
  68. </div>
  69. </div>
  70. <div class="inline field">
  71. <label></label>
  72. {{template "custom/task_wait_count" .}}
  73. </div>
  74. <div class="inline required field">
  75. <label>{{.i18n.Tr "cloudbrain.task_name"}}</label>
  76. <input name="display_job_name" id="cloudbrain_job_name"
  77. placeholder="{{.i18n.Tr "cloudbrain.task_name"}}" value="{{.display_job_name}}" tabindex="3"
  78. autofocus required maxlength="255" onkeyup="this.value=this.value.replace(/[, ]/g,'')">
  79. </div>
  80. <div class="inline required field">
  81. <label>{{.i18n.Tr "cloudbrain.task_type"}}</label>
  82. <select id="cloudbrain_job_type" class="ui search dropdown"
  83. placeholder="{{.i18n.Tr "cloudbrain.task_type"}}" style='width:385px' name="job_type">
  84. <option name="job_type" value="DEBUG">DEBUG</option>
  85. </select>
  86. </div>
  87. <div class="inline required field cloudbrain_benchmark">
  88. <label style="vertical-align: top; margin-top:9px">数据集类别</label>
  89. <select class="ui search dropdown" multiple="multiple" id="cloudbrain_benchmark_category"
  90. style='width:385px'>
  91. {{range .benchmark_categories}}
  92. <option value="{{.Value}}">{{.Value}}</option>
  93. {{end}}
  94. </select>
  95. <div class="mini ui buttons" style="vertical-align: top; margin-top:9px">
  96. <button class="ui button reset">重置</button>
  97. <div class="or"></div>
  98. <button class="ui positive button active all_selected">全选</button>
  99. </div>
  100. </div>
  101. <input id="store_category" type="hidden" name="get_benchmark_category">
  102. <div class="inline required field">
  103. <label>{{.i18n.Tr "repo.modelarts.code_version"}}</label>
  104. <select class="ui dropdown width80 left2 {{if not .Branches}}error{{end}}" id="code_version"
  105. name="branch_name">
  106. {{if .branch_name}}
  107. <option name="branch_name" value="{{.branch_name}}">{{.branch_name}}</option>
  108. {{range $k, $v :=.Branches}}
  109. {{ if ne $v $.branch_name }}
  110. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  111. {{end}}
  112. {{end}}
  113. {{else}}
  114. <option name="branch_name" value="{{.branchName}}">{{.branchName}}</option>
  115. {{range $k, $v :=.Branches}}
  116. {{ if ne $v $.branchName }}
  117. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  118. {{end}}
  119. {{end}}
  120. {{end}}
  121. </select>
  122. </div>
  123. <div id="images-new-cb">
  124. </div>
  125. <div id="select-multi-dataset">
  126. </div>
  127. <div class="inline required field">
  128. <label>{{.i18n.Tr "cloudbrain.resource_specification"}}</label>
  129. <select id="__specs__" class="ui search dropdown"
  130. placeholder="{{.i18n.Tr "cloudbrain.select_specification"}}" style='width:385px' ovalue="{{.spec_id}}"
  131. {{if .CloudBrainPaySwitch}}blance="{{.PointAccount.Balance}}"{{end}}
  132. name="spec_id">
  133. </select>
  134. <span><i class="question circle icon link"></i></span>
  135. <a href="{{AppSubUrl}}/resource_desc" target="_blank">{{.i18n.Tr "custom.resource_description"}}</a>
  136. {{if .CloudBrainPaySwitch}}
  137. <div class="cloudbrain_resource_spec_blance_tip" style="padding:0 5px;margin:6px 0;margin-left:265px;font-size:12px;width: 50%!important;">
  138. <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>
  139. <span style="float:right;">
  140. <i class="question circle icon link" data-position="right center" data-variation="mini"></i>
  141. <a href="{{AppSubUrl}}/reward/point/rule" target="_blank">{{$.i18n.Tr "points.points_acquisition_instructions"}}</a>
  142. </span>
  143. </div>
  144. {{end}}
  145. </div>
  146. <div class="inline required field">
  147. <label>{{.i18n.Tr "cloudbrain.dataset_storage_path"}}</label>
  148. <input name="dataset_path" id="cloudbrain_dataset_path" value="{{.dataset_path}}" tabindex="3"
  149. disabled autofocus required maxlength="255" readonly="readonly">
  150. </div>
  151. <div class="inline required field">
  152. <label>{{.i18n.Tr "cloudbrain.model_storage_path"}}</label>
  153. <input name="model_path" id="cloudbrain_model_path" value="{{.model_path}}" tabindex="3"
  154. disabled autofocus required maxlength="255" readonly="readonly">
  155. </div>
  156. <div class="inline required field">
  157. <label>{{.i18n.Tr "cloudbrain.code_storage_path"}}</label>
  158. <input name="code_path" id="cloudbrain_code_path" value="{{.code_path}}" tabindex="3" disabled
  159. autofocus required maxlength="255" readonly="readonly">
  160. </div>
  161. <div class="inline required field cloudbrain_benchmark">
  162. <label>{{.i18n.Tr "cloudbrain.benchmark_path"}}</label>
  163. <input name="benchmark_path" id="cloudbrain_benchmark_path" value="{{.benchmark_path}}"
  164. tabindex="3" disabled autofocus required maxlength="255" readonly="readonly">
  165. </div>
  166. <div class="inline required field cloudbrain_snn4imagenet">
  167. <label>{{.i18n.Tr "cloudbrain.snn4imagenet_path"}}</label>
  168. <input name="snn4imagenet_path" id="cloudbrain_snn4imagenet_path" value="{{.snn4imagenet_path}}"
  169. tabindex="3" disabled autofocus required maxlength="255" readonly="readonly">
  170. </div>
  171. <div class="inline required field cloudbrain_brainscore">
  172. <label>{{.i18n.Tr "cloudbrain.brainscore_path"}}</label>
  173. <input name="brainscore_path" id="cloudbrain_brainscore_path" value="{{.brainscore_path}}"
  174. tabindex="3" disabled autofocus required maxlength="255" readonly="readonly">
  175. </div>
  176. <div class="inline required field" hidden>
  177. <label>{{.i18n.Tr "cloudbrain.start_command"}}</label>
  178. <textarea name="command" rows="10" readonly="readonly">{{.command}}</textarea>
  179. </div>
  180. <div class="inline field">
  181. <label></label>
  182. <button class="ui green button {{if eq .NotStopTaskCount 1}}disabled{{end}}">
  183. {{.i18n.Tr "repo.cloudbrain.new"}}
  184. </button>
  185. <a class="ui button cancel"
  186. href="{{.RepoLink}}/debugjob?debugListType=all">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  187. </div>
  188. </div>
  189. </form>
  190. </div>
  191. </div>
  192. </div>
  193. {{template "base/footer" .}}
  194. <script src="{{StaticUrlPrefix}}/js/specsuse.js?v={{MD5 AppVer}}" type="text/javascript"></script>
  195. <script>
  196. let form = document.getElementById('form_id');
  197. $('#messageInfo').css('display', 'none')
  198. function clearValue() {
  199. context = inputs[0]
  200. context.value = ''
  201. $(".icon.icons").css("visibility", "hidden")
  202. }
  203. var isValidate = false;
  204. function validate(){
  205. $('.ui.form').form({
  206. on: 'blur',
  207. fields: {
  208. display_job_name:{
  209. identifier : 'display_job_name',
  210. rules: [
  211. {
  212. type: 'regExp[/^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$/]',
  213. }
  214. ]
  215. },
  216. spec_id: {
  217. identifier: 'spec_id',
  218. rules: [{ type: 'empty' }]
  219. }
  220. },
  221. onSuccess: function(){
  222. isValidate = true;
  223. },
  224. onFailure: function(e){
  225. isValidate = false;
  226. return false;
  227. }
  228. })
  229. }
  230. validate();
  231. let createFlag = false
  232. form.onsubmit = function (e) {
  233. if (!isValidate) return false;
  234. if(createFlag) return false
  235. let value_task = $("input[name='display_job_name']").val()
  236. let value_image = $("input[name='image']").val()
  237. let value_data = $("input[name='attachment']").val()
  238. let re = /^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$/
  239. let flag = re.test(value_task)
  240. if (!flag) {
  241. $('#messageInfo').css('display', 'block')
  242. let str = '只能以小写字母或数字开头且只包含小写字母、数字、_和-,不能以_结尾,最长36个字符。'
  243. $('#messageInfo p').text(str)
  244. return false
  245. }
  246. let min_value_task = value_task.toLowerCase()
  247. $("input[name='display_job_name']").attr("value", min_value_task)
  248. createFlag = true
  249. document.getElementById("mask").style.display = "block"
  250. }
  251. // 页面加载完毕后遮罩层隐藏
  252. document.onreadystatechange = function () {
  253. if (document.readyState === "complete") {
  254. document.getElementById("mask").style.display = "none"
  255. }
  256. }
  257. $('#cloudbrain_benchmark_category')
  258. .dropdown({
  259. placeholder: "选择数据集类别",
  260. })
  261. $(".ui.button.reset").click(function (e) {
  262. e.preventDefault()
  263. $('#cloudbrain_benchmark_category')
  264. .dropdown("clear", true)
  265. })
  266. $(".ui.positive.button.active.all_selected").click(function (e) {
  267. e.preventDefault()
  268. var selected_value = new Array()
  269. $("#cloudbrain_benchmark_category option").each(function () {
  270. selected_value.push($(this).val())
  271. });
  272. $('#cloudbrain_benchmark_category')
  273. .dropdown("set exactly", selected_value)
  274. })
  275. $('.ui.green.button').click(function () {
  276. if (!$('input[name="isBranches"]').val()) {
  277. return false
  278. }
  279. selected_value = $("#cloudbrain_benchmark_category").val()
  280. $('#store_category').attr("value", selected_value)
  281. validate();
  282. })
  283. ;(function() {
  284. var SPECS = {{ .debug_specs }};
  285. var showPoint = {{ .CloudBrainPaySwitch }};
  286. window.renderSpecsSelect($('#__specs__'), SPECS, showPoint, {
  287. gpu_memory: {{$.i18n.Tr "cloudbrain.gpu_memory"}},
  288. free: {{$.i18n.Tr "cloudbrain.free"}},
  289. point_hr: {{$.i18n.Tr "cloudbrain.point_hr"}},
  290. memory: {{$.i18n.Tr "cloudbrain.memory"}},
  291. shared_memory: {{$.i18n.Tr "cloudbrain.shared_memory"}},
  292. });
  293. })();
  294. console.log({{.debug_specs}})
  295. </script>