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.

profiling.vue 16 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <!--
  2. Copyright 2020 Huawei Technologies Co., Ltd.All Rights Reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. -->
  13. <template>
  14. <div class="prof-wrap">
  15. <div class="prof-content">
  16. <div class="prof-content-left"
  17. :class="{collapse:collapse}">
  18. <div class="helper"
  19. v-show="!collapse">
  20. <div class="summary-path">
  21. {{$t('trainingDashboard.summaryDirPath')}}
  22. <span>{{ summaryPath}}</span>
  23. </div>
  24. <div class="cur-card">
  25. <label>{{$t('profiling.curCard')}}</label>
  26. <el-select v-model="curDashboardInfo.curCardNum"
  27. class="card-select"
  28. :placeholder="$t('public.select')"
  29. @change="selectValueChange">
  30. <el-option v-for="item in CardNumArr"
  31. :key="item.value"
  32. :label="item.value + $t('operator.card')"
  33. :value="item.value">
  34. </el-option>
  35. </el-select>
  36. </div>
  37. <div class="helper-title">
  38. {{$t("profiling.smartHelper")}}
  39. </div>
  40. <div class="suggested-title">{{$t("profiling.suggestions")}}</div>
  41. <div id="helper-tips"></div>
  42. </div>
  43. <div class="collapse-btn"
  44. :class="{collapse:collapse}"
  45. @click="collapseLeft()">
  46. </div>
  47. </div>
  48. <div class="prof-content-right"
  49. :class="{collapse:collapse}">
  50. <router-view></router-view>
  51. <div class="close"
  52. @click="backToDdashboard"
  53. v-if="$route.path !== '/profiling-gpu/profiling-dashboard'">
  54. <img src="@/assets/images/close-page.png">
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </template>
  60. <script>
  61. import RequestService from '../../services/request-service';
  62. export default {
  63. data() {
  64. return {
  65. summaryPath: this.$route.query.summaryPath,
  66. tipsArrayList: [
  67. 'step_trace-iter_interval',
  68. 'minddata_pipeline-general',
  69. 'minddata_pipeline-dataset_op',
  70. 'minddata_pipeline-generator_op',
  71. 'minddata_pipeline-map_op',
  72. 'minddata_pipeline-batch_op',
  73. 'minddata_warning_op',
  74. ],
  75. moreParameter: ['minddata_device_queue', 'minddata_get_next_queue'],
  76. CardNumArr: [], // Card list
  77. collapse: false,
  78. curDashboardInfo: {
  79. // Current Select card info
  80. curCardNum: '',
  81. query: {},
  82. },
  83. };
  84. },
  85. watch: {},
  86. mounted() {
  87. this.$nextTick(() => {
  88. this.init();
  89. });
  90. },
  91. methods: {
  92. /**
  93. * Init function
  94. */
  95. init() {
  96. if (this.$route.query && this.$route.query.id && this.$route.query.dir) {
  97. this.curDashboardInfo.query.id = this.$route.query.id;
  98. this.curDashboardInfo.query.dir = this.$route.query.dir;
  99. this.curDashboardInfo.query.path = this.$route.query.path;
  100. this.getDeviceList();
  101. } else {
  102. this.curDashboardInfo.query.trainingJobId = '';
  103. this.curDashboardInfo.query.dir = '';
  104. this.curDashboardInfo.query.path = '';
  105. this.$message.error(this.$t('trainingDashboard.invalidId'));
  106. }
  107. },
  108. /**
  109. * When card mumber changed,request data again.
  110. */
  111. selectValueChange() {
  112. const helperDiv = document.getElementById('helper-tips');
  113. helperDiv.innerHTML = '';
  114. this.getDataOfProfileHelper();
  115. },
  116. /**
  117. * Get card number list
  118. */
  119. getDeviceList() {
  120. const params = {
  121. profile: this.curDashboardInfo.query.dir,
  122. train_id: this.curDashboardInfo.query.id,
  123. };
  124. RequestService.getProfilerDeviceData(params)
  125. .then(
  126. (res) => {
  127. if (res && res.data && res.data.length) {
  128. const deviceList = res.data;
  129. deviceList.forEach((item) => {
  130. this.CardNumArr.push({
  131. value: item,
  132. });
  133. });
  134. this.curDashboardInfo.curCardNum = this.CardNumArr[0].value;
  135. this.getDataOfProfileHelper();
  136. } else {
  137. this.CardNumArr = [];
  138. this.curDashboardInfo.curCardNum = '';
  139. this.curDashboardInfo.initOver = true;
  140. }
  141. },
  142. (error) => {
  143. this.CardNumArr = [];
  144. this.curDashboardInfo.curCardNum = '';
  145. this.curDashboardInfo.initOver = true;
  146. },
  147. )
  148. .catch(() => {
  149. this.curDashboardInfo.initOver = true;
  150. });
  151. },
  152. /**
  153. * Get profile helper data
  154. */
  155. getDataOfProfileHelper() {
  156. const params = {
  157. train_id: this.curDashboardInfo.query.id,
  158. profile: this.curDashboardInfo.query.dir,
  159. device_id: this.curDashboardInfo.curCardNum.toString()
  160. ? this.curDashboardInfo.curCardNum.toString()
  161. : '0',
  162. };
  163. RequestService.queryDataOfProfileHelper(params)
  164. .then((resp) => {
  165. if (resp && resp.data) {
  166. const dataKeys = Object.keys(resp.data);
  167. const helperDiv = document.getElementById('helper-tips');
  168. helperDiv.innerHTML = '';
  169. dataKeys.forEach((item) => {
  170. if (
  171. !this.tipsArrayList.includes(item) &&
  172. !this.moreParameter.includes(item) &&
  173. resp.data[item]
  174. ) {
  175. this.$t(`profiling`)[item] = resp.data[item];
  176. }
  177. if (item.endsWith('type_label')) {
  178. const divDom = document.createElement('div');
  179. divDom.setAttribute('class', 'suggested-items-style');
  180. divDom.innerHTML = `<div class="helper-icon"></div>
  181. <div class="helper-container-title">
  182. ${this.$t(`profiling`)[item].desc}
  183. </div>`;
  184. helperDiv.appendChild(divDom);
  185. } else if (this.tipsArrayList.includes(item)) {
  186. const divDom = document.createElement('div');
  187. divDom.setAttribute('class', 'content-style');
  188. const content = `${this.$t(`profiling`)[item].desc}`.replace(
  189. `{n1}`,
  190. resp.data[item][0],
  191. );
  192. divDom.innerHTML = `<div class="content-icon el-icon-caret-right"></div>
  193. <div class="helper-content-style">${content}</div>`;
  194. helperDiv.appendChild(divDom);
  195. } else if (item === 'minddata_device_queue') {
  196. const deviceEmpty =
  197. resp.data['minddata_device_queue'][0] >= 0
  198. ? resp.data['minddata_device_queue'][0]
  199. : '--';
  200. const deviceTotal =
  201. resp.data['minddata_device_queue'][1] >= 0
  202. ? resp.data['minddata_device_queue'][1]
  203. : '--';
  204. const deviceFull =
  205. resp.data['minddata_device_queue'][2] >= 0
  206. ? resp.data['minddata_device_queue'][2]
  207. : '--';
  208. const divDom = document.createElement('div');
  209. divDom.setAttribute('class', 'content-style');
  210. const content = `${this.$t(`profiling`)[item].desc}`
  211. .replace(
  212. `{n1}`,
  213. `<span class="nowrap-style"> ${deviceEmpty}</span>`,
  214. )
  215. .replace(
  216. `{n2}`,
  217. `<span class="nowrap-style"> ${deviceTotal}</span>`,
  218. )
  219. .replace(
  220. `{n3}`,
  221. `<span class="nowrap-style"> ${deviceFull}</span>`,
  222. )
  223. .replace(
  224. `{n4}`,
  225. `<span class="nowrap-style"> ${deviceTotal}</span>`,
  226. );
  227. divDom.innerHTML = `<div class="content-icon el-icon-caret-right"></div>
  228. <div class="helper-content-style">${content}</div>`;
  229. helperDiv.appendChild(divDom);
  230. } else if (item === 'minddata_get_next_queue') {
  231. const getNextEmpty =
  232. resp.data['minddata_get_next_queue'][0] >= 0
  233. ? resp.data['minddata_get_next_queue'][0]
  234. : '--';
  235. const getNextTotal =
  236. resp.data['minddata_get_next_queue'][1] >= 0
  237. ? resp.data['minddata_get_next_queue'][1]
  238. : '--';
  239. const divDom = document.createElement('div');
  240. divDom.setAttribute('class', 'content-style');
  241. const content = `${this.$t(`profiling`)[item].desc}`
  242. .replace(
  243. `{n1}`,
  244. `<span class="nowrap-style"> ${getNextEmpty}</span>`,
  245. )
  246. .replace(
  247. `{n2}`,
  248. `<span class="nowrap-style"> ${getNextTotal}</span>`,
  249. );
  250. divDom.innerHTML = `<div class="content-icon el-icon-caret-right"></div>
  251. <div class="helper-content-style">${content}</div>`;
  252. helperDiv.appendChild(divDom);
  253. } else if (this.$t(`profiling`)[item].anchor) {
  254. if (this.$t(`profiling`)[item].anchor.length === 1) {
  255. const divDom = document.createElement('div');
  256. divDom.setAttribute('class', 'content-style');
  257. divDom.innerHTML = `<div class="content-icon el-icon-caret-right"></div>
  258. <div class="helper-content-style">
  259. <a target="_blank" href="${this.$t(`profiling`)[item].url[0]}">
  260. ${this.$t(`profiling`)[item].desc}</a></div>`;
  261. helperDiv.appendChild(divDom);
  262. } else {
  263. const divDom = document.createElement('div');
  264. divDom.setAttribute('class', 'content-style');
  265. const anchorList = this.$t(`profiling`)[item].anchor;
  266. let anchorContent = this.$t(`profiling`)[item].desc;
  267. for (let i = 0; i < anchorList.length; i++) {
  268. const desc = anchorContent.relpace(
  269. anchorList[i],
  270. `<a target="_blank" href="${
  271. this.$t(`profiling`)[item].url[i]
  272. }">
  273. ${anchorList[i]}</a>`,
  274. );
  275. anchorContent = desc;
  276. }
  277. divDom.innerHTML = `<div class="content-icon el-icon-caret-right">
  278. </div><div class="helper-content-style">${anchorContent}</div>`;
  279. helperDiv.appendChild(divDom);
  280. }
  281. } else {
  282. const divDom = document.createElement('div');
  283. divDom.setAttribute('class', 'content-style');
  284. divDom.innerHTML = `${this.$t(`profiling`)[item].desc}`;
  285. helperDiv.appendChild(divDom);
  286. }
  287. });
  288. }
  289. })
  290. .catch(() => {});
  291. },
  292. /**
  293. * Router back to profiling-dashboard
  294. */
  295. backToDdashboard() {
  296. this.$router.push({
  297. path: '/profiling-gpu/profiling-dashboard',
  298. query: {
  299. dir: this.curDashboardInfo.query.dir,
  300. id: this.curDashboardInfo.query.id,
  301. path: this.curDashboardInfo.query.path,
  302. },
  303. });
  304. },
  305. collapseLeft() {
  306. this.collapse = !this.collapse;
  307. this.$bus.$emit('collapse');
  308. },
  309. },
  310. destroyed() {
  311. this.$bus.$off('collapse');
  312. },
  313. };
  314. </script>
  315. <style lang="scss">
  316. .prof-wrap {
  317. height: 100%;
  318. background: #fff;
  319. .prof-content {
  320. height: 100%;
  321. padding: 24px 24px 24px 0;
  322. & > div {
  323. float: left;
  324. height: 100%;
  325. }
  326. .prof-content-left {
  327. width: 22%;
  328. transition: width 0.2s;
  329. position: relative;
  330. .el-input__inner {
  331. padding: 0 10px;
  332. }
  333. .helper {
  334. padding: 32px;
  335. padding-top: 20px;
  336. height: 100%;
  337. overflow-y: auto;
  338. margin-left: 24px;
  339. background: #edf0f5;
  340. word-wrap: break-word;
  341. .summary-path {
  342. line-height: 24px;
  343. font-size: 14px;
  344. overflow: hidden;
  345. font-weight: bold;
  346. padding-bottom: 10px;
  347. word-break: break-all;
  348. text-overflow: -o-ellipsis-lastline;
  349. overflow: hidden;
  350. text-overflow: ellipsis;
  351. display: -webkit-box;
  352. -webkit-line-clamp: 4;
  353. -webkit-box-orient: vertical;
  354. }
  355. .nowrap-style {
  356. white-space: nowrap;
  357. }
  358. .cur-card {
  359. margin-bottom: 32px;
  360. .card-select {
  361. width: calc(100% - 120px);
  362. }
  363. & > label {
  364. margin-right: 14px;
  365. }
  366. }
  367. .helper-title {
  368. font-size: 20px;
  369. font-weight: bold;
  370. margin-bottom: 32px;
  371. .el-icon-rank {
  372. float: right;
  373. cursor: pointer;
  374. }
  375. }
  376. .helper-container-title {
  377. display: inline-block;
  378. padding: 0 6px;
  379. }
  380. .helper-icon {
  381. display: inline-block;
  382. width: 6px;
  383. height: 6px;
  384. margin-top: 6px;
  385. border-radius: 3px;
  386. background-color: #00a5a7;
  387. }
  388. .suggested-title {
  389. font-weight: bold;
  390. margin-bottom: 20px;
  391. font-size: 16px;
  392. }
  393. .container-bottom {
  394. margin-bottom: 16px;
  395. }
  396. .suggested-items-style {
  397. display: flex;
  398. font-weight: bold;
  399. margin-bottom: 6px;
  400. margin-top: 10px;
  401. }
  402. .helper-content-style {
  403. margin-left: 6px;
  404. line-height: 20px;
  405. word-break: break-all;
  406. text-overflow: ellipsis;
  407. overflow: hidden;
  408. display: -webkit-box;
  409. -webkit-box-orient: vertical;
  410. -webkit-line-clamp: 8;
  411. }
  412. }
  413. .content-icon {
  414. color: #00a5a7;
  415. padding-top: 3px;
  416. }
  417. .content-style {
  418. display: flex;
  419. }
  420. .collapse-btn {
  421. position: absolute;
  422. right: -21px;
  423. width: 31px;
  424. height: 100px;
  425. top: 50%;
  426. margin-top: -50px;
  427. cursor: pointer;
  428. line-height: 86px;
  429. z-index: 1;
  430. text-align: center;
  431. background-image: url('../../assets/images/collapse-left.svg');
  432. }
  433. .collapse-btn.collapse {
  434. background-image: url('../../assets/images/collapse-right.svg');
  435. }
  436. }
  437. .prof-content-left.collapse {
  438. width: 0;
  439. }
  440. .prof-content-right {
  441. width: 78%;
  442. padding-left: 20px;
  443. transition: width 0.2s;
  444. position: relative;
  445. .close {
  446. position: absolute;
  447. right: 0;
  448. top: -10px;
  449. cursor: pointer;
  450. }
  451. }
  452. .prof-content-right.collapse {
  453. width: 100%;
  454. }
  455. }
  456. }
  457. </style>