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.

convertshowinfo.tmpl 39 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. {{template "base/head" .}}
  2. <style>
  3. .according-panel-heading{
  4. box-sizing: border-box;
  5. padding: 8px 16px;
  6. color: #252b3a;
  7. background-color: #f2f5fc;
  8. line-height: 1.5;
  9. cursor: pointer;
  10. -moz-user-select: none;
  11. -webkit-user-select: none;
  12. -ms-user-select: none;
  13. -khtml-user-select: none;
  14. user-select: none;
  15. }
  16. .accordion-panel-title {
  17. margin-top: 0;
  18. margin-bottom: 0;
  19. color: #252b3a;
  20. }
  21. .accordion-panel-title-content{
  22. vertical-align: middle;
  23. display: inline-block;
  24. width: calc(100% - 32px);
  25. cursor: default;
  26. }
  27. .acc-margin-bottom {
  28. margin-bottom: 5px;
  29. }
  30. .title_text {
  31. font-size: 12px;
  32. }
  33. .ac-display-inblock {
  34. display: inline-block;
  35. }
  36. .cti-mgRight-sm {
  37. margin-right: 8px;
  38. }
  39. .ac-text-normal {
  40. font-size: 14px;
  41. color: #575d6c;
  42. }
  43. .uc-accordionTitle-black {
  44. color: #333;
  45. }
  46. .accordion-border{
  47. border:1px solid #cce2ff;
  48. }
  49. .padding0{
  50. padding: 0 !important;
  51. }
  52. .content-pad{
  53. padding: 15px 35px;
  54. }
  55. .content-margin{
  56. margin:10px 5px ;
  57. }
  58. .tab_2_content {
  59. min-height: 360px;
  60. margin-left: 10px;
  61. }
  62. .ac-grid {
  63. display: block;
  64. *zoom: 1;
  65. }
  66. .ac-grid-col {
  67. float: left;
  68. width: 100%;
  69. }
  70. .ac-grid-col2 .ac-grid-col {
  71. width: 50%;
  72. }
  73. .ti-form {
  74. text-align: left;
  75. max-width: 100%;
  76. vertical-align: middle;
  77. }
  78. .ti-form>tbody {
  79. font-size: 12px;
  80. }
  81. .ti-form>tbody, .ti-form>tbody>tr {
  82. vertical-align: inherit;
  83. }
  84. .ti-text-form-label {
  85. padding-bottom: 20px;
  86. padding-right: 20px;
  87. color: #8a8e99;
  88. font-size: 12px;
  89. white-space: nowrap !important;
  90. width: 80px;
  91. line-height: 30px;
  92. }
  93. .ti-text-form-content{
  94. line-height: 30px;
  95. padding-bottom: 20px;
  96. }
  97. .ti-form>tbody>tr>td {
  98. vertical-align: top;
  99. white-space: normal;
  100. }
  101. td, th {
  102. padding: 0;
  103. }
  104. .info_text {
  105. padding-bottom: 20px;
  106. padding-right: 20px;
  107. font-size: 12px;
  108. }
  109. .ac-grid-col .text-span {
  110. width: 450px;
  111. overflow: hidden;
  112. text-overflow: ellipsis;
  113. white-space: nowrap;
  114. }
  115. .redo-color{
  116. color: #3291F8;
  117. }
  118. .ti-action-menu-item:not(:last-child){
  119. margin-right: 10px;
  120. padding-right: 11px;
  121. text-decoration: none!important;
  122. color: #526ecc;
  123. cursor: pointer;
  124. display: inline-block;
  125. -moz-user-select: none;
  126. -webkit-user-select: none;
  127. -ms-user-select: none;
  128. -khtml-user-select: none;
  129. user-select: none;
  130. position: relative;
  131. }
  132. .ti-action-menu-item:not(:last-child):after {
  133. content: "";
  134. display: inline-block;
  135. position: absolute;
  136. height: 12px;
  137. right: 0;
  138. top: 50%;
  139. -webkit-transform: translateY(-6px);
  140. -ms-transform: translateY(-6px);
  141. -o-transform: translateY(-6px);
  142. transform: translateY(-6px);
  143. border-right: 1px solid #dfe1e6;
  144. }
  145. .text-width80{
  146. width: 100px;
  147. line-height: 30px;
  148. }
  149. .border-according-model{
  150. border: 1px solid #dfe1e6;
  151. }
  152. .disabled {
  153. cursor: default;
  154. pointer-events: none;
  155. color: rgba(0,0,0,.6) !important;
  156. opacity: .45 !important;
  157. }
  158. .pad20{
  159. border:0px !important;
  160. }
  161. .model_file_bread{
  162. margin-bottom: -0.5rem !important;
  163. padding-left: 1rem;
  164. padding-top: 0.5rem ;
  165. }
  166. </style>
  167. <div id="mask">
  168. <div id="loadingPage">
  169. <div class="rect1"></div>
  170. <div class="rect2"></div>
  171. <div class="rect3"></div>
  172. <div class="rect4"></div>
  173. <div class="rect5"></div>
  174. </div>
  175. </div>
  176. <div class="repository">
  177. {{template "repo/header" .}}
  178. <div class="ui container">
  179. <h4 class="ui header" id="vertical-segment">
  180. <div class="ui breadcrumb">
  181. <a class="section" href="{{$.RepoLink}}/modelmanage/convert_model">
  182. 模型转换任务
  183. </a>
  184. <div class="divider"> / </div>
  185. <div class="active section">{{.Name}}</div>
  186. </div>
  187. </h4>
  188. {{with .task}}
  189. <div class="ui accordion border-according-model" id="accordion" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.CloudBrainTaskId}}" data-version="1">
  190. <input type="hidden" id="jobId_input" name="jobId_input" value="{{.CloudBrainTaskId}}">
  191. <div class="active title padding0">
  192. <div class="according-panel-heading">
  193. <div class="accordion-panel-title">
  194. <i class="dropdown icon"></i>
  195. <span class="accordion-panel-title-content">
  196. <span>
  197. <div class="ac-display-inblock title_text acc-margin-bottom">
  198. <span class="cti-mgRight-sm">{{TimeSinceUnix1 .CreatedUnix}}</span>
  199. <span class="cti-mgRight-sm">{{$.i18n.Tr "repo.modelarts.status"}}:
  200. <span id="status-span"><i id="icon" style="vertical-align: middle;" class="{{.Status}}"></i><span id="text" style="margin-left: 0.4em;font-size: 12px;">{{.Status}}</span></span>
  201. </span>
  202. <span class="cti-mgRight-sm">{{$.i18n.Tr "repo.modelarts.train_job.dura_time"}}:</span>
  203. <span class="cti-mgRight-sm uc-accordionTitle-black" id="duration-span">{{.TrainJobDuration}}</span>
  204. </div>
  205. </span>
  206. </span>
  207. </div>
  208. </div>
  209. </div>
  210. <div class="active content">
  211. <div class="content-pad">
  212. <div class="ui pointing secondary menu" style="border-bottom: 1px solid rgba(34,36,38,.15);">
  213. <a class="active item" data-tab="first">{{$.i18n.Tr "repo.modelarts.train_job.config"}}</a>
  214. <a id="gpuruntimeinfo" style="display: {{$.gpu_display}};" class="item" data-tab="second" onclick="javascript:parseInfo()">{{$.i18n.Tr "repo.cloudbrain.runinfo"}}</a>
  215. <a id="gpulog" style="display: {{$.gpu_display}};" class="item" data-tab="third" onclick="loadLog()">{{$.i18n.Tr "repo.modelarts.log"}}</a>
  216. <a id="npulog" style="display: {{$.npu_display}};" class="item log_bottom" data-tab="five" data-version="">{{$.i18n.Tr "repo.modelarts.log"}}</a>
  217. <a class="item" data-tab="four" onclick="loadModelFile()">{{$.i18n.Tr "repo.model_download"}}</a>
  218. </div>
  219. <div class="ui tab active" data-tab="first">
  220. <div style="padding-top: 10px;">
  221. <div class="tab_2_content">
  222. <div class="ac-grid ac-grid-col2">
  223. <div class="ac-grid-col">
  224. <table class="ti-form">
  225. <tbody class="ti-text-form">
  226. <tr class="ti-no-ng-animate">
  227. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  228. {{$.i18n.Tr "repo.cloudbrain_task"}}
  229. </td>
  230. <td class="ti-text-form-content">
  231. <div class="text-span text-span-w">
  232. {{.Name}}
  233. </div>
  234. </td>
  235. </tr>
  236. <tr class="ti-no-ng-animate">
  237. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  238. {{$.i18n.Tr "repo.modelarts.status"}}
  239. </td>
  240. <td class="ti-text-form-content">
  241. <div class="text-span text-span-w" id="status">
  242. {{.Status}}
  243. </div>
  244. </td>
  245. </tr>
  246. <tr class="ti-no-ng-animate">
  247. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  248. 输入张量形状
  249. </td>
  250. <td class="ti-text-form-content">
  251. <div class="text-span text-span-w" id="InputShape">
  252. {{.InputShape}}
  253. </div>
  254. </td>
  255. </tr>
  256. <tr class="ti-no-ng-animate">
  257. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  258. 输入数据格式
  259. </td>
  260. <td class="ti-text-form-content">
  261. <div class="text-span text-span-w" id="InputDataFormat">
  262. {{.InputDataFormat}}
  263. </div>
  264. </td>
  265. </tr>
  266. <tr class="ti-no-ng-animate">
  267. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  268. {{$.i18n.Tr "repo.modelarts.train_job.start_time"}}
  269. </td>
  270. <td class="ti-text-form-content">
  271. <div class="text-span text-span-w">
  272. <span style="font-size: 12px;" class="">{{TimeSinceUnix1 .CreatedUnix}}</span>
  273. </div>
  274. </td>
  275. </tr>
  276. <tr class="ti-no-ng-animate">
  277. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  278. {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}}
  279. </td>
  280. <td class="ti-text-form-content">
  281. <div class="text-span text-span-w" id="duration">
  282. {{.TrainJobDuration}}
  283. </div>
  284. </td>
  285. </tr>
  286. <tr class="ti-no-ng-animate">
  287. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  288. 网络输出数据类型
  289. </td>
  290. <td class="ti-text-form-content">
  291. <div class="text-span text-span-w" id="duration">
  292. {{if eq .NetOutputFormat 0}}FP32 {{else if eq .NetOutputFormat 1}}FP16 {{end}}
  293. </div>
  294. </td>
  295. </tr>
  296. </tbody>
  297. </table>
  298. </div>
  299. <div class="ac-grid-col">
  300. <table class="ti-form">
  301. <tbody class="ti-text-form">
  302. <tr class="ti-no-ng-animate">
  303. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  304. 模型名称
  305. </td>
  306. <td class="ti-text-form-content">
  307. <div class="text-span text-span-w">
  308. {{.ModelName}}
  309. </div>
  310. </td>
  311. </tr>
  312. <tr class="ti-no-ng-animate">
  313. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  314. 模型版本
  315. </td>
  316. <td class="ti-text-form-content">
  317. <div class="text-span text-span-w">
  318. {{.ModelVersion}}
  319. </div>
  320. </td>
  321. </tr>
  322. <tr class="ti-no-ng-animate">
  323. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  324. 模型文件
  325. </td>
  326. <td class="ti-text-form-content">
  327. <div class="text-span text-span-w">
  328. {{.ModelPath}}
  329. </div>
  330. </td>
  331. </tr>
  332. <tr class="ti-no-ng-animate">
  333. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  334. 原模型框架
  335. </td>
  336. <td class="ti-text-form-content">
  337. <div class="text-span text-span-w">
  338. {{if eq .SrcEngine 0}}PyTorch {{else if eq .SrcEngine 1}}Tensorflow{{else if eq .SrcEngine 2}}MindSpore {{end}}
  339. </div>
  340. </td>
  341. </tr>
  342. <tr class="ti-no-ng-animate">
  343. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  344. 转换后格式
  345. </td>
  346. <td class="ti-text-form-content">
  347. <div class="text-span text-span-w">
  348. {{if eq .DestFormat 0}}ONNX {{else if eq .DestFormat 1}}TensorRT {{end}}
  349. </div>
  350. </td>
  351. </tr>
  352. <tr class="ti-no-ng-animate">
  353. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  354. {{$.i18n.Tr "repo.modelarts.train_job.description"}}
  355. </td>
  356. <td class="ti-text-form-content">
  357. <div class="text-span text-span-w" title="{{.Description}}">
  358. {{.Description}}
  359. </div>
  360. </td>
  361. </tr>
  362. <tr class="ti-no-ng-animate">
  363. <td class="ti-no-ng-animate ti-text-form-label text-width80">
  364. {{$.i18n.Tr "repo.cloudbrain_creator"}}
  365. </td>
  366. <td class="ti-text-form-content">
  367. <div class="text-span text-span-w" id="username">
  368. {{.UserName}}
  369. </div>
  370. </td>
  371. </tr>
  372. </tbody>
  373. </table>
  374. </div>
  375. </div>
  376. </div>
  377. </div>
  378. </div>
  379. <div class="ui tab" data-tab="second">
  380. <div>
  381. <div class="ui message message" style="display: none;">
  382. <div id="header"></div>
  383. </div>
  384. <div class="ui attached log" id="log" style="height: 390px !important; overflow: auto;">
  385. <input type="hidden" id="json_value" value="{{$.AppExitDiagnostics}}">
  386. <input type="hidden" id="ExitDiagnostics" value="{{$.ExitDiagnostics}}">
  387. <span id="info_display" class="info_text">
  388. </span>
  389. </div>
  390. </div>
  391. </div>
  392. <div class="ui tab" data-tab="third">
  393. <div>
  394. <div class="ui message message" style="display: none;">
  395. <div id="header"></div>
  396. </div>
  397. <div class="ui attached log" id="log" style="height: 300px !important; overflow: auto;">
  398. <input type="hidden" name="end_line">
  399. <input type="hidden" name="start_line">
  400. <pre id="log_file"></pre>
  401. </div>
  402. </div>
  403. </div>
  404. <div class="ui tab" data-tab="five">
  405. <div style="position: relative;">
  406. <span>
  407. <a title="滚动到顶部" style="position: absolute; right: -32px;cursor: pointer;" class="log_top" data-version="V0001"><i class="icon-to-top"></i></a>
  408. </span>
  409. <span>
  410. <a title="滚动到底部" style="position: absolute; bottom: 10px;right: -32px;cursor: pointer;" class="log_bottom" data-version="V0001"><i class="icon-to-bottom"></i></a>
  411. </span>
  412. <div id="log_npu_message" class="ui message message" style="display: none;">
  413. <div id="log_npu_header"></div>
  414. </div>
  415. <div class="ui attached log" onscroll="fn()" id="log_npu" style="height: 300px !important; overflow: auto;">
  416. <input type="hidden" name="end_line" value>
  417. <input type="hidden" name="start_line" value>
  418. <pre id="log_file_npu"></pre>
  419. </div>
  420. </div>
  421. </div>
  422. <div class="ui tab" data-tab="four">
  423. <input type="hidden" name="model" value="-1">
  424. <input type="hidden" name="modelback" value="-1">
  425. <div class='ui breadcrumb model_file_bread' id='file_breadcrumb'>
  426. <div class="active section"></div>
  427. <div class="divider"> / </div>
  428. </div>
  429. <div id="dir_list">
  430. </div>
  431. </div>
  432. </div>
  433. </div>
  434. </div>
  435. {{end}} {{template "base/paginate" .}}
  436. </div>
  437. <!-- 确认模态框 -->
  438. </div>
  439. {{template "base/footer" .}}
  440. <script>
  441. $('.menu .item').tab()
  442. $(document).ready(function(){
  443. $('.ui.accordion').accordion({selector:{trigger:'.icon'}});
  444. });
  445. $(document).ready(function(){
  446. $('.secondary.menu .item').tab();
  447. });
  448. let userName
  449. let repoPath
  450. let jobID = {{$.task.CloudBrainTaskId}}
  451. let downlaodFlag = {{$.canDownload}}
  452. let taskID = {{$.task.ID}}
  453. let realJobName = {{$.task.ID}}
  454. $(document).ready(function(){
  455. let url = window.location.href;
  456. let urlArr = url.split('/')
  457. userName = urlArr.slice(-4)[0]
  458. repoPath = urlArr.slice(-3)[0]
  459. console.log("userName=" + userName + " repoPath=" + repoPath);
  460. })
  461. function stopBubbling(e) {
  462. e = window.event || e;
  463. if (e.stopPropagation) {
  464. e.stopPropagation(); //阻止事件 冒泡传播
  465. } else {
  466. e.cancelBubble = true; //ie兼容
  467. }
  468. }
  469. let timeid = window.setInterval(loadJobStatus, 30000);
  470. $(document).ready(loadJobStatus);
  471. function loadLog(version_name){
  472. document.getElementById("mask").style.display = "block"
  473. $.get(`/api/v1/repos/${userName}/${repoPath}/modelmanage/${taskID}/log?version_name=${version_name}&lines=50&order=asc`, (data) => {
  474. $('input[name=end_line]').val(data.EndLine)
  475. $('input[name=start_line]').val(data.StartLine)
  476. $(`#log_file`).text(data.Content)
  477. document.getElementById("mask").style.display = "none"
  478. }).fail(function(err) {
  479. console.log(err);
  480. document.getElementById("mask").style.display = "none"
  481. });
  482. }
  483. function loadModelFile(version_name,parents,filename,init){
  484. parents = parents || ''
  485. filename = filename || ''
  486. init = init || ''
  487. console.log("start")
  488. $.get(`/api/v1/repos/${userName}/${repoPath}/modelmanage/${taskID}/model_list?version_name=${version_name}&parentDir=${parents}`, (data) => {
  489. $(`#dir_list`).empty()
  490. renderDir(data,version_name)
  491. if(init==="init"){
  492. $(`input[name=model]`).val("")
  493. $(`input[name=modelback]`).val(version_name)
  494. $(`#file_breadcrumb`).empty()
  495. let htmlBread = "/"
  496. $(`#file_breadcrumb`).append(htmlBread)
  497. }else{
  498. renderBrend(version_name,parents,filename,init)
  499. }
  500. }).fail(function(err) {
  501. console.log(err,version_name);
  502. });
  503. }
  504. function renderBrend(version_name,parents,filename,init){
  505. if(init=="folder"){
  506. let htmlBrend = ""
  507. let sectionName=$(`#file_breadcrumb .active.section`).text()
  508. let parents1 = $(`input[name=model]`).val()
  509. let filename1 = $(`input[name=modelback]`).val()
  510. if(parents1===""){
  511. $(`#file_breadcrumb .active.section`).replaceWith(`<a class='section' onclick="loadModelFile('${version_name}','${parents1}','','init')">${sectionName}</a>`)
  512. }else{
  513. $(`#file_breadcrumb .active.section`).replaceWith(`<a class='section' onclick="loadModelFile('${version_name}','${parents1}','${filename1}')">${sectionName}</a>`)
  514. }
  515. htmlBrend += `<div class='active section'>${filename}</div>`
  516. htmlBrend += "<div class='divider'> / </div>"
  517. $(`#file_breadcrumb`).append(htmlBrend)
  518. $(`input[name=model]`).val(parents)
  519. $(`input[name=modelback]`).val(filename)
  520. }else{
  521. $(`input[name=model]`).val(parents)
  522. $(`input[name=modelback]`).val(filename)
  523. $(`#file_breadcrumb a.section:contains(${filename})`).nextAll().remove()
  524. $(`#file_breadcrumb a.section:contains(${filename})`).replaceWith(`<div class='active section'>${filename}</div>`)
  525. //$(`#file_breadcrumb div.section:contains(${filename})`).append("<div class='divider'> / </div>")
  526. }
  527. }
  528. function renderDir(data,version_name){
  529. let html=""
  530. html += "<div class='ui grid' style='margin:0;'>"
  531. html += "<div class='row' style='padding: 0;'>"
  532. html += "<div class='ui sixteen wide column' style='padding:1rem;'>"
  533. html += "<div class='dir list'>"
  534. html += "<table id='repo-files-table' class='ui single line table pad20'>"
  535. html += '<tbody>'
  536. for(let i=0;i<data.Dirs.length;i++){
  537. let dirs_size = renderSize(data.Dirs[i].Size)
  538. html += "<tr>"
  539. html += "<td class='name six wid'>"
  540. html += "<span class='truncate'>"
  541. html += "<span class='octicon octicon-file-directory'>"
  542. html += "</span>"
  543. if(data.Dirs[i].IsDir){
  544. html += `<a onclick="loadModelFile('${version_name}','${data.Dirs[i].ParenDir}','${data.Dirs[i].FileName}','folder')">`
  545. html += "<span class='fitted'><i class='folder icon' width='16' height='16' aria-hidden='true'></i>" + data.Dirs[i].FileName + "</span>"
  546. }else{
  547. if(downlaodFlag){
  548. html += `<a href="/${userName}/${repoPath}/modelmanage/download_model_convert/${taskID}?fileName=${data.Dirs[i].FileName}&parentDir=${data.Dirs[i].ParenDir}&jobName=${realJobName}">`
  549. }
  550. else{
  551. html += `<a class="disabled">`
  552. }
  553. html += "<span class='fitted'><i class='file icon' width='16' height='16' aria-hidden='true'></i>" + data.Dirs[i].FileName + "</span>"
  554. }
  555. html += '</a>'
  556. html += "</span>"
  557. html += "</td>"
  558. html += "<td class='message seven wide'>"
  559. if(data.Dirs[i].IsDir){
  560. html += "<span class='truncate has-emoji'></span>"
  561. }else{
  562. html += "<span class='truncate has-emoji'>"+ `${dirs_size}` + "</span>"
  563. }
  564. html += "</td>"
  565. html += "<td class='text right age three wide'>"
  566. html += "<span class='truncate has-emoji'>" + data.Dirs[i].ModTime + "</span>"
  567. html += "</td>"
  568. html += "</tr>"
  569. }
  570. html += "</tbody>"
  571. html += "</table>"
  572. html += "</div>"
  573. html += "</div>"
  574. html += "</div>"
  575. html += "</div>"
  576. $(`#dir_list`).append(html)
  577. }
  578. function renderSize(value){
  579. if(null==value||value==''){
  580. return "0 Bytes";
  581. }
  582. var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
  583. var index=0;
  584. var srcsize = parseFloat(value);
  585. index=Math.floor(Math.log(srcsize)/Math.log(1024));
  586. var size =srcsize/Math.pow(1024,index);
  587. size=size.toFixed(0);//保留的小数位数
  588. return size+unitArr[index];
  589. }
  590. function loadJobStatus() {
  591. $(".ui.accordion.border-according-model").each((index, job) => {
  592. const jobID = job.dataset.jobid;
  593. const repoPath = job.dataset.repopath;
  594. const versionname = job.dataset.version
  595. let status = $(`#status-span`).text()
  596. if(['IMAGE_FAILED','SUBMIT_FAILED','DELETE_FAILED','KILLED','COMPLETED','FAILED','CANCELED','LOST','START_FAILED','SUCCEEDED','STOPPED'].includes(status)){
  597. return
  598. }
  599. let stopArray=["KILLED","FAILED","START_FAILED","KILLING","COMPLETED","SUCCEEDED","STOPPED"]
  600. $.get(`/api/v1/repos/${repoPath}/modelmanage/${taskID}?version_name=${versionname}`, (data) => {
  601. $(`#status-span span`).text(data.JobStatus)
  602. $(`#status-span i`).attr("class",data.JobStatus)
  603. $('#status').text(data.JobStatus)
  604. }).fail(function(err) {
  605. console.log(err);
  606. });
  607. });
  608. };
  609. function parseInfo(){
  610. let jsonValue = document.getElementById("json_value").value;
  611. let jsonObj = JSON.parse(jsonValue);
  612. let podRoleName = jsonObj["podRoleName"];
  613. let html = "";
  614. if (podRoleName != null){
  615. let task0 = podRoleName["task1-0"];
  616. let podEvents = jsonObj["podEvents"];
  617. let podEventArray = podEvents[task0];
  618. if(podEventArray != null){
  619. for(var i=0; i < podEventArray.length;i++){
  620. if (podEventArray[i]["reason"]!="") {
  621. html +="<p><b>[" +podEventArray[i]["reason"] + "]</b></p>";
  622. html +="<p>" +podEventArray[i]["message"] + "</p>";
  623. html +="<p>" +podEventArray[i]["action"] + "</p>";
  624. }
  625. }
  626. }
  627. let extras= jsonObj["extras"];
  628. if(extras != null){
  629. for(var i=0; i < extras.length;i++){
  630. if (extras[i]["reason"]!="") {
  631. html +="<p><b>[" +extras[i]["reason"] + "]</b></p>";
  632. html +="<p>" +extras[i]["message"] + "</p>";
  633. html +="<p>" +extras[i]["action"] + "</p>";
  634. }
  635. }
  636. }
  637. }
  638. let string = document.getElementById("ExitDiagnostics").value;
  639. string = string.replace(/\r\n/g,"<br>")
  640. string = string.replace(/\n/g,"<br>");
  641. string = string.replace(/(\r\n)|(\n)/g,'<br>');
  642. if (string!=""){
  643. html +="<p><b>[ExitDiagnostics]</b></p>";
  644. html +="<p>" +string + "</p>";
  645. }
  646. document.getElementById("info_display").innerHTML=html;
  647. }
  648. function debounce(fn,delay){
  649. let timer;
  650. return (...args) => {
  651. // 判断定时器是否存在,清除定时器
  652. if (timer) {
  653. clearTimeout(timer);
  654. }
  655. // 重新调用setTimeout
  656. timer = setTimeout(() => {
  657. fn.apply(this, args);
  658. }, delay);
  659. };
  660. }
  661. const fn = debounce(logScroll, 500)
  662. function logScroll(version_name) {
  663. let container = document.querySelector(`#log_npu`)
  664. let scrollTop = container.scrollTop
  665. let scrollHeight = container.scrollHeight
  666. let clientHeight = container.clientHeight
  667. let scrollLeft = container.scrollLeft
  668. if(((parseInt(scrollTop) + clientHeight == scrollHeight || parseInt(scrollTop) + clientHeight +1 == scrollHeight || parseInt(scrollTop) + clientHeight - 1 == scrollHeight)) && parseInt(scrollTop)!==0 && scrollLeft==0){
  669. let end_line = $(`#log_npu input[name=end_line]`).val()
  670. $.get(`/api/v1/repos/${userName}/${repoPath}/modelmanage/${taskID}/modelartlog?version_name=V0001&base_line=${end_line}&lines=50&order=desc`, (data) => {
  671. if (data.Lines == 0){
  672. $(`#log_npu_header`).text('您已翻阅至日志底部')
  673. $(`#log_npu_message`).css('display', 'block')
  674. setTimeout(function(){
  675. $(`#log_npu_message`).css('display', 'none')
  676. }, 1000)
  677. }else{
  678. if(end_line===data.EndLine){
  679. return
  680. }
  681. else{
  682. $(`#log_npu input[name=end_line]`).val(data.EndLine)
  683. $(`#log_npu`).append('<pre>' + data.Content)
  684. }
  685. }
  686. }).fail(function(err) {
  687. console.log(err);
  688. });
  689. }
  690. if([0,1,2,3,4,5,6,7,8,9,10].includes(scrollTop) && scrollLeft==0){
  691. let start_line = $(`#log_npu input[name=start_line]`).val()
  692. $.get(`/api/v1/repos/${userName}/${repoPath}/modelmanage/${taskID}/modelartlog?version_name=V0001&base_line=${start_line}&lines=50&order=asc`, (data) => {
  693. if (data.Lines == 0){
  694. $(`#log_npu_header`).text('您已翻阅至日志顶部')
  695. $(`#log_npu_message`).css('display', 'block')
  696. setTimeout(function(){
  697. $(`#log_npu_message`).css('display', 'none')
  698. }, 1000)
  699. }else{
  700. $(`#log_npu input[name=start_line]`).val(data.StartLine) //如果变动就改变所对应的值
  701. $(`#log_npu`).prepend('<pre>' + data.Content)
  702. }
  703. }).fail(function(err) {
  704. console.log(err);
  705. });
  706. }
  707. }
  708. function scrollAnimation(dom, currentY, targetY, currentX) {
  709. let needScrollTop = targetY - currentY;
  710. let _currentY = currentY;
  711. setTimeout(() => {
  712. // 一次调用滑动帧数,每次调用会不一样
  713. //取总距离的十分之一
  714. const dist = Math.ceil(needScrollTop / 10);
  715. _currentY += dist;
  716. //移动一个十分之一
  717. dom.scrollTo(currentX || 0, _currentY,'smooth');
  718. // 如果移动幅度小于十个像素,直接移动,否则递归调用,实现动画效果
  719. if (needScrollTop > 10 || needScrollTop < -10) {
  720. scrollAnimation(dom, _currentY, targetY)
  721. } else {
  722. dom.scrollTo(0, targetY,'smooth')
  723. }
  724. }, 1)
  725. }
  726. $('.log_top').click(function(){
  727. let logContentDom = document.querySelector(`#log_npu`)
  728. $(`#log_file_npu`).siblings('pre').remove()
  729. $.get(`/api/v1/repos/${userName}/${repoPath}/modelmanage/${taskID}/modelartlog?version_name=V0001&base_line=&lines=50&order=asc`, (data) => {
  730. $(`#log_npu input[name=end_line]`).val(data.EndLine) //如果变动就改变所对应的值
  731. $(`#log_npu input[name=start_line]`).val(data.StartLine)
  732. $(`#log_npu`).prepend('<pre>' + data.Content)
  733. $(`#log_npu_header`).text('您已翻阅至日志顶部')
  734. $(`#log_npu_message`).css('display', 'block')
  735. setTimeout(function(){
  736. $(`#log_npu_message`).css('display', 'none')
  737. }, 1000)
  738. scrollAnimation(logContentDom, logContentDom.scrollTop, 0);
  739. })
  740. })
  741. $('.log_bottom').click(function(e){
  742. let logContentDom = document.querySelector(`#log_npu`)
  743. $(`#log_file_npu`).siblings('pre').remove()
  744. $.get(`/api/v1/repos/${userName}/${repoPath}/modelmanage/${taskID}/modelartlog?version_name=V0001&base_line=&lines=50&order=desc`, (data) => {
  745. $(`#log_npu input[name=end_line]`).val(data.EndLine) //如果变动就改变所对应的值
  746. $(`#log_npu input[name=start_line]`).val(data.StartLine)
  747. $(`#log_npu`).append('<pre>' + data.Content)
  748. $.get(`/api/v1/repos/${userName}/${repoPath}/modelmanage/${taskID}/modelartlog?version_name=V0001&base_line=${data.EndLine}&lines=50&order=desc`, (data) => {
  749. if (data.Lines == 0){
  750. $(`#log_npu_header`).text('您已翻阅至日志底部')
  751. $(`#log_npu_message`).css('display', 'block')
  752. setTimeout(function(){
  753. $(`#log_npu_message`).css('display', 'none')
  754. }, 1000)
  755. }else{
  756. if(end_line===data.EndLine){
  757. return
  758. }
  759. else{
  760. $(`#log_npu input[name=end_line]`).val(data.EndLine)
  761. $(`#log_npu`).append('<pre>' + data.Content)
  762. }
  763. }
  764. }).fail(function(err) {
  765. console.log(err);
  766. });
  767. scrollAnimation(logContentDom, logContentDom.scrollTop+1, logContentDom.scrollHeight - logContentDom.clientHeight);
  768. })
  769. })
  770. </script>