提交 bfbe5e87 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!505 Optimized ui page initialization

Merge pull request !505 from 冯学峰/myMaster02
...@@ -60,7 +60,8 @@ limitations under the License. ...@@ -60,7 +60,8 @@ limitations under the License.
</div> </div>
<div class="trace-container"> <div class="trace-container">
<div id="trace" <div id="trace"
class="training-trace"> class="training-trace"
:style="{height: svg.totalHeight + 'px'}">
<svg version="1.1" <svg version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
height="100%" height="100%"
...@@ -525,6 +526,10 @@ export default { ...@@ -525,6 +526,10 @@ export default {
} }
}); });
}, },
/**
* router link
* @param { String } path router path
*/
viewDetail(path) { viewDetail(path) {
this.$router.push({ this.$router.push({
path, path,
...@@ -535,6 +540,9 @@ export default { ...@@ -535,6 +540,9 @@ export default {
}, },
}); });
}, },
/**
* chart setOption
*/
setPieOption() { setPieOption() {
const option = {}; const option = {};
option.tooltip = { option.tooltip = {
...@@ -580,6 +588,9 @@ export default { ...@@ -580,6 +588,9 @@ export default {
this.pieChart.chartDom.resize(); this.pieChart.chartDom.resize();
}, 10); }, 10);
}, },
/**
* init chart
*/
initPieChart() { initPieChart() {
const params = {}; const params = {};
params.params = { params.params = {
...@@ -650,7 +661,8 @@ export default { ...@@ -650,7 +661,8 @@ export default {
(res) => { (res) => {
this.svg.initOver = true; this.svg.initOver = true;
if ( if (
res.data && res &&
res.data &&
res.data.training_trace_graph && res.data.training_trace_graph &&
res.data.training_trace_graph.length res.data.training_trace_graph.length
) { ) {
...@@ -677,14 +689,14 @@ export default { ...@@ -677,14 +689,14 @@ export default {
this.tail_percent = '--'; this.tail_percent = '--';
} }
} else { } else {
document.querySelector('#trace').style.height = '0px'; this.svg.totalHeight = 0;
this.svg.noData = true; this.svg.noData = true;
this.svg.data = []; this.svg.data = [];
this.removeTrace(); this.removeTrace();
} }
}, },
(error) => { (error) => {
document.querySelector('#trace').style.height = '0px'; this.svg.totalHeight = 0;
this.svg.noData = true; this.svg.noData = true;
this.svg.data = []; this.svg.data = [];
this.svg.initOver = true; this.svg.initOver = true;
...@@ -740,9 +752,6 @@ export default { ...@@ -740,9 +752,6 @@ export default {
}); });
this.svg.totalHeight += this.svg.rowPadding; this.svg.totalHeight += this.svg.rowPadding;
document.querySelector(
'#trace',
).style.height = `${this.svg.totalHeight}px`;
this.svg.data = JSON.parse(JSON.stringify(data)); this.svg.data = JSON.parse(JSON.stringify(data));
this.$nextTick(() => { this.$nextTick(() => {
...@@ -853,7 +862,7 @@ export default { ...@@ -853,7 +862,7 @@ export default {
break; break;
} }
const textContent = `${name}: ${data.duration.toFixed(4)}ms`; const textContent = `${name}: ${this.toFixedFun(data.duration, 4)}ms`;
const textWidth = this.getTextWidth(textContent); const textWidth = this.getTextWidth(textContent);
const normalSize = data.duration >= this.svg.minTime; const normalSize = data.duration >= this.svg.minTime;
...@@ -932,7 +941,7 @@ export default { ...@@ -932,7 +941,7 @@ export default {
data.duration === this.svg.totalTime data.duration === this.svg.totalTime
? this.$t('profiling.approximateTime') ? this.$t('profiling.approximateTime')
: '' : ''
}${data.duration.toFixed(4)}ms`; }${this.toFixedFun(data.duration, 4)}ms`;
const textWidth = text.textContent const textWidth = text.textContent
? this.getTextWidth(text.textContent) ? this.getTextWidth(text.textContent)
: 0; : 0;
...@@ -1020,7 +1029,10 @@ export default { ...@@ -1020,7 +1029,10 @@ export default {
this.timelineInfo.initOver = true; this.timelineInfo.initOver = true;
if (res && res.data) { if (res && res.data) {
this.timelineInfo.noData = false; this.timelineInfo.noData = false;
this.timelineInfo.totalTime = res.data.total_time.toFixed(4); this.timelineInfo.totalTime = this.toFixedFun(
res.data.total_time,
4,
);
this.timelineInfo.streamNum = res.data.num_of_streams; this.timelineInfo.streamNum = res.data.num_of_streams;
this.timelineInfo.opNum = res.data.num_of_ops; this.timelineInfo.opNum = res.data.num_of_ops;
this.timelineInfo.opTimes = res.data.op_exe_times; this.timelineInfo.opTimes = res.data.op_exe_times;
...@@ -1100,6 +1112,18 @@ export default { ...@@ -1100,6 +1112,18 @@ export default {
const timestamp = `${year}${mouth}${day}${hour}${minute}${second}${millisecond}`; const timestamp = `${year}${mouth}${day}${hour}${minute}${second}${millisecond}`;
return `timeline_${this.trainingJobId}_${this.currentCard}_${timestamp}.json`; return `timeline_${this.trainingJobId}_${this.currentCard}_${timestamp}.json`;
}, },
/**
* Keep the number with n decimal places.
* @param {Number} num
* @param {Number} pow Number of decimal places
* @return {Number}
*/
toFixedFun(num, pow) {
if (isNaN(num) || isNaN(pow) || !num || !pow) {
return num;
}
return Math.round(num * Math.pow(10, pow)) / Math.pow(10, pow);
},
}, },
destroyed() { destroyed() {
window.removeEventListener('resize', this.resizeTrace, false); window.removeEventListener('resize', this.resizeTrace, false);
......
...@@ -57,7 +57,8 @@ limitations under the License. ...@@ -57,7 +57,8 @@ limitations under the License.
<div class="pf-content-middle"> <div class="pf-content-middle">
<div id="trace-container"> <div id="trace-container">
<div id="trace" <div id="trace"
class="training-trace"> class="training-trace"
:style="{height: svg.totalHeight + 'px'}">
<svg version="1.1" <svg version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
height="100%" height="100%"
...@@ -313,7 +314,7 @@ export default { ...@@ -313,7 +314,7 @@ export default {
}; };
RequestService.targetTimeInfo(params).then( RequestService.targetTimeInfo(params).then(
(res) => { (res) => {
if (res.data && res.data.summary) { if (res && res.data && res.data.summary) {
const summary = res.data.summary; const summary = res.data.summary;
Object.keys(summary).forEach((val) => { Object.keys(summary).forEach((val) => {
summary[val] = summary[val]; summary[val] = summary[val];
...@@ -324,7 +325,7 @@ export default { ...@@ -324,7 +325,7 @@ export default {
} }
}); });
} }
if (res.data && res.data.info) { if (res && res.data && res.data.info) {
if (res.data.size && !this.steps.max) { if (res.data.size && !this.steps.max) {
this.steps.max = res.data.size; this.steps.max = res.data.size;
this.steps.disabled = false; this.steps.disabled = false;
...@@ -439,7 +440,8 @@ export default { ...@@ -439,7 +440,8 @@ export default {
(res) => { (res) => {
this.svg.initOver = true; this.svg.initOver = true;
if ( if (
res.data && res &&
res.data &&
res.data.training_trace_graph && res.data.training_trace_graph &&
res.data.training_trace_graph.length res.data.training_trace_graph.length
) { ) {
...@@ -527,9 +529,6 @@ export default { ...@@ -527,9 +529,6 @@ export default {
}); });
this.svg.totalHeight += this.svg.rowPadding; this.svg.totalHeight += this.svg.rowPadding;
document.querySelector(
'#trace',
).style.height = `${this.svg.totalHeight}px`;
this.svg.data = JSON.parse(JSON.stringify(data)); this.svg.data = JSON.parse(JSON.stringify(data));
this.$nextTick(() => { this.$nextTick(() => {
...@@ -640,7 +639,7 @@ export default { ...@@ -640,7 +639,7 @@ export default {
break; break;
} }
const textContent = `${name}: ${data.duration.toFixed(4)}ms`; const textContent = `${name}: ${this.toFixedFun(data.duration, 4)}ms`;
const textWidth = this.getTextWidth(textContent); const textWidth = this.getTextWidth(textContent);
const normalSize = data.duration >= this.svg.minTime; const normalSize = data.duration >= this.svg.minTime;
...@@ -719,7 +718,7 @@ export default { ...@@ -719,7 +718,7 @@ export default {
data.duration === this.svg.totalTime data.duration === this.svg.totalTime
? this.$t('profiling.approximateTime') ? this.$t('profiling.approximateTime')
: '' : ''
}${data.duration.toFixed(4)}ms`; }${this.toFixedFun(data.duration, 4)}ms`;
const textWidth = text.textContent const textWidth = text.textContent
? this.getTextWidth(text.textContent) ? this.getTextWidth(text.textContent)
: 0; : 0;
...@@ -789,6 +788,18 @@ export default { ...@@ -789,6 +788,18 @@ export default {
this.svg.resizeTimer = null; this.svg.resizeTimer = null;
}, 500); }, 500);
}, },
/**
* Keep the number with n decimal places.
* @param {Number} num
* @param {Number} pow Number of decimal places
* @return {Number}
*/
toFixedFun(num, pow) {
if (isNaN(num) || isNaN(pow) || !num || !pow) {
return num;
}
return Math.round(num * Math.pow(10, pow)) / Math.pow(10, pow);
},
}, },
destroyed() { destroyed() {
window.removeEventListener('resize', this.resizeTrace, false); window.removeEventListener('resize', this.resizeTrace, false);
......
...@@ -105,9 +105,14 @@ limitations under the License. ...@@ -105,9 +105,14 @@ limitations under the License.
v-show="!firstFloorNodes.length || wrongPlugin"> v-show="!firstFloorNodes.length || wrongPlugin">
<img :src="require('@/assets/images/nodata.png')" <img :src="require('@/assets/images/nodata.png')"
alt="" /> alt="" />
<p class='no-data-text'> <p v-if="initOverKey.graph"
class='no-data-text'>
{{$t("public.noData")}} {{$t("public.noData")}}
</p> </p>
<p v-else
class='no-data-text'>
{{$t("public.dataLoading")}}
</p>
</div> </div>
</div> </div>
</div> </div>
...@@ -124,9 +129,14 @@ limitations under the License. ...@@ -124,9 +129,14 @@ limitations under the License.
v-show="!showDatasetGraph || wrongPlugin"> v-show="!showDatasetGraph || wrongPlugin">
<img :src="require('@/assets/images/nodata.png')" <img :src="require('@/assets/images/nodata.png')"
alt="" /> alt="" />
<p class='no-data-text'> <p v-if="initOverKey.dataMap"
class='no-data-text'>
{{$t("public.noData")}} {{$t("public.noData")}}
</p> </p>
<p v-else
class='no-data-text'>
{{$t("public.dataLoading")}}
</p>
</div> </div>
</div> </div>
</div> </div>
...@@ -267,6 +277,8 @@ export default { ...@@ -267,6 +277,8 @@ export default {
image: false, image: false,
tensor: false, tensor: false,
scalar: false, scalar: false,
graph: false,
dataMap: false,
}, },
}; };
}, },
...@@ -405,6 +417,8 @@ export default { ...@@ -405,6 +417,8 @@ export default {
image: true, image: true,
tensor: true, tensor: true,
scalar: true, scalar: true,
graph: true,
dataMap: true,
}; };
return; return;
} }
...@@ -423,6 +437,8 @@ export default { ...@@ -423,6 +437,8 @@ export default {
this.dealTensorData(tensorTags); this.dealTensorData(tensorTags);
if (!this.firstFloorNodes.length && graphIds.length) { if (!this.firstFloorNodes.length && graphIds.length) {
this.queryGraphData(); this.queryGraphData();
} else {
this.initOverKey.graph = true;
} }
}) })
.catch((error) => { .catch((error) => {
...@@ -431,6 +447,8 @@ export default { ...@@ -431,6 +447,8 @@ export default {
image: true, image: true,
tensor: true, tensor: true,
scalar: true, scalar: true,
graph: true,
dataMap: true,
}; };
if ( if (
!error.response || !error.response ||
...@@ -575,7 +593,7 @@ export default { ...@@ -575,7 +593,7 @@ export default {
this.charOption = {}; this.charOption = {};
this.charData = []; this.charData = [];
this.curPageArr = []; this.curPageArr = [];
this.initOverKey.scalar=true; this.initOverKey.scalar = true;
return; return;
} }
const params = { const params = {
...@@ -590,7 +608,7 @@ export default { ...@@ -590,7 +608,7 @@ export default {
!res.data.train_jobs || !res.data.train_jobs ||
!res.data.train_jobs.length !res.data.train_jobs.length
) { ) {
this.initOverKey.scalar=true; this.initOverKey.scalar = true;
return; return;
} }
if (res.data && res.data.error_code) { if (res.data && res.data.error_code) {
...@@ -640,7 +658,7 @@ export default { ...@@ -640,7 +658,7 @@ export default {
} }
}, this.errorScalar) }, this.errorScalar)
.catch((e) => { .catch((e) => {
this.initOverKey.scalar=true; this.initOverKey.scalar = true;
}); });
}, },
/** /**
...@@ -1507,6 +1525,7 @@ export default { ...@@ -1507,6 +1525,7 @@ export default {
.dot(dot) .dot(dot)
.attributer(this.attributer) .attributer(this.attributer)
.render(() => { .render(() => {
this.initOverKey.graph = true;
if (d3.select('#graph svg')) { if (d3.select('#graph svg')) {
d3.select('#graph svg').on('.zoom', null); d3.select('#graph svg').on('.zoom', null);
} }
...@@ -1530,18 +1549,27 @@ export default { ...@@ -1530,18 +1549,27 @@ export default {
RequestService.queryGraphData(params) RequestService.queryGraphData(params)
.then( .then(
(response) => { (response) => {
if (response && response.data && response.data.nodes) { if (
response &&
response.data &&
response.data.nodes &&
response.data.nodes.length
) {
const nodes = response.data.nodes; const nodes = response.data.nodes;
if (nodes && nodes.length) { this.packageDataToObject(nodes);
this.packageDataToObject(nodes); const dot = this.packageGraphData();
const dot = this.packageGraphData(); this.initGraph(dot);
this.initGraph(dot); } else {
} this.initOverKey.graph = true;
} }
}, },
(error) => {}, (error) => {
this.initOverKey.graph = true;
},
) )
.catch((e) => {}); .catch((e) => {
this.initOverKey.graph = true;
});
}, },
/** /**
* Processes its own and corresponding child node data when expanding or closing namespaces. * Processes its own and corresponding child node data when expanding or closing namespaces.
...@@ -1861,11 +1889,17 @@ export default { ...@@ -1861,11 +1889,17 @@ export default {
const dot = this.packageDatasetGraph(); const dot = this.packageDatasetGraph();
this.initDatasetGraph(dot); this.initDatasetGraph(dot);
} }
} else {
this.initOverKey.dataMap = true;
} }
}, },
(err) => {}, (err) => {
this.initOverKey.dataMap = true;
},
) )
.catch((e) => {}); .catch((e) => {
this.initOverKey.dataMap = true;
});
}, },
/** /**
* Processing dataset Graph Data * Processing dataset Graph Data
...@@ -1877,8 +1911,9 @@ export default { ...@@ -1877,8 +1911,9 @@ export default {
if (!data) { if (!data) {
return; return;
} }
const key = `${parentKey ? parentKey + '/' : ''}${data.op_type || const key = `${parentKey ? parentKey + '/' : ''}${
''}_${index}`; data.op_type || ''
}_${index}`;
const obj = { const obj = {
key: key, key: key,
id: '', id: '',
...@@ -1993,6 +2028,7 @@ export default { ...@@ -1993,6 +2028,7 @@ export default {
*/ */
afterinitDatasetGraph() { afterinitDatasetGraph() {
this.showDatasetGraph = true; this.showDatasetGraph = true;
this.initOverKey.dataMap = true;
if (d3.select('#dataMapGraph svg')) { if (d3.select('#dataMapGraph svg')) {
d3.select('#dataMapGraph svg').on('.zoom', null); d3.select('#dataMapGraph svg').on('.zoom', null);
} }
...@@ -2003,9 +2039,7 @@ export default { ...@@ -2003,9 +2039,7 @@ export default {
this.datasetGraphviz = null; this.datasetGraphviz = null;
} }
}, 100); }, 100);
d3.select('#dataMapGraph') d3.select('#dataMapGraph').selectAll('title').remove();
.selectAll('title')
.remove();
}, },
/** /**
* Query the cachee status of training jonb * Query the cachee status of training jonb
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册