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

!272 fix graph bug which can not open aggregation scope node

Merge pull request !272 from WeiFeng-mindinsight/myMaster
...@@ -15,58 +15,56 @@ limitations under the License. ...@@ -15,58 +15,56 @@ limitations under the License.
--> -->
<template> <template>
<div <div class="el-autocomplete"
class="el-autocomplete" v-clickoutside="close"
v-clickoutside="close" aria-haspopup="listbox"
aria-haspopup="listbox" role="combobox"
role="combobox" :aria-expanded="suggestionVisible"
:aria-expanded="suggestionVisible" :aria-owns="id">
:aria-owns="id" <el-input ref="input"
> class="rtl-item"
<el-input v-bind="[$props, $attrs]"
ref="input" @input="handleChange"
v-bind="[$props, $attrs]" @focus="handleFocus"
@input="handleChange" @blur="handleBlur"
@focus="handleFocus" @clear="handleClear"
@blur="handleBlur" @keydown.up.native.prevent="highlight(highlightedIndex - 1)"
@clear="handleClear" @keydown.down.native.prevent="highlight(highlightedIndex + 1)"
@keydown.up.native.prevent="highlight(highlightedIndex - 1)" @keydown.enter.native="handleKeyEnter"
@keydown.down.native.prevent="highlight(highlightedIndex + 1)" @keydown.native.tab="close">
@keydown.enter.native="handleKeyEnter" <template slot="prepend"
@keydown.native.tab="close" v-if="$slots.prepend">
>
<template slot="prepend" v-if="$slots.prepend">
<slot name="prepend"></slot> <slot name="prepend"></slot>
</template> </template>
<template slot="append" v-if="$slots.append"> <template slot="append"
v-if="$slots.append">
<slot name="append"></slot> <slot name="append"></slot>
</template> </template>
<template slot="prefix" v-if="$slots.prefix"> <template slot="prefix"
v-if="$slots.prefix">
<slot name="prefix"></slot> <slot name="prefix"></slot>
</template> </template>
<template slot="suffix" v-if="$slots.suffix"> <template slot="suffix"
v-if="$slots.suffix">
<slot name="suffix"></slot> <slot name="suffix"></slot>
</template> </template>
</el-input> </el-input>
<el-autocomplete-suggestions <el-autocomplete-suggestions visible-arrow
visible-arrow :class="[popperClass ? popperClass : '']"
:class="[popperClass ? popperClass : '']" :suggestions-has-data="suggestionsHasData"
:suggestions-has-data="suggestionsHasData" :popper-options="popperOptions"
:popper-options="popperOptions" :append-to-body="popperAppendToBody"
:append-to-body="popperAppendToBody" ref="suggestions"
ref="suggestions" :placement="placement"
:placement="placement" :id="id">
:id="id" <li v-for="(item, index) in suggestions"
> :key="index"
<li :class="{ highlighted: highlightedIndex === index }"
v-for="(item, index) in suggestions" class="rtl-item"
:key="index" @click="select(item)"
:class="{ highlighted: highlightedIndex === index }" :id="`${id}-item-${index}`"
@click="select(item)" role="option"
:id="`${id}-item-${index}`" :aria-selected="highlightedIndex === index">
role="option"
:aria-selected="highlightedIndex === index"
>
<slot :item="item"> <slot :item="item">
<span :title="item[valueKey]">{{ item[valueKey] }}</span> <span :title="item[valueKey]">{{ item[valueKey] }}</span>
</slot> </slot>
...@@ -91,3 +89,10 @@ export default { ...@@ -91,3 +89,10 @@ export default {
}, },
}; };
</script> </script>
<style lang="scss" scoped>
.rtl-item {
text-align: right;
direction: rtl;
text-overflow: ellipsis;
}
</style>
...@@ -205,7 +205,8 @@ ...@@ -205,7 +205,8 @@
"guideContent3": "计算图中存在数据边和控制边。其中数据边表示数据的输入,控制边表示节点之间执行依赖关系。", "guideContent3": "计算图中存在数据边和控制边。其中数据边表示数据的输入,控制边表示节点之间执行依赖关系。",
"next": "下一步", "next": "下一步",
"finish": "完成", "finish": "完成",
"dataTooLarge": "节点和边的数量过多,导致打开失败" "dataTooLarge": "节点和边的数量过多,导致打开失败",
"tooManyChain": "直接子节点的深度超过70,不支持展开"
}, },
"operator": { "operator": {
"titleText": "性能分析", "titleText": "性能分析",
......
...@@ -450,6 +450,7 @@ export default { ...@@ -450,6 +450,7 @@ export default {
trainJobID: '', trainJobID: '',
frameSpace: 25, // Distance between the namespace border and the internal node frameSpace: 25, // Distance between the namespace border and the internal node
nodesCountLimit: 1500, // Maximum number of sub-nodes in a namespace. nodesCountLimit: 1500, // Maximum number of sub-nodes in a namespace.
maxChainNum: 70,
curColorIndex: 0, curColorIndex: 0,
// Node search box // Node search box
searchBox: { searchBox: {
...@@ -992,6 +993,16 @@ export default { ...@@ -992,6 +993,16 @@ export default {
} else { } else {
if (this.allGraphData[name].type === 'aggregation_scope') { if (this.allGraphData[name].type === 'aggregation_scope') {
this.dealAggregationNodes(name); this.dealAggregationNodes(name);
if (
this.allGraphData[name].maxChainNum > this.maxChainNum
) {
this.$message.error(this.$t('graph.tooManyChain'));
this.allGraphData[name].isUnfold = true;
this.selectedNode.name = name;
this.loading.show = false;
this.deleteNamespace(name);
return;
}
} }
this.allGraphData[name].isUnfold = true; this.allGraphData[name].isUnfold = true;
this.selectedNode.name = `${name}_unfold`; this.selectedNode.name = `${name}_unfold`;
...@@ -1075,12 +1086,15 @@ export default { ...@@ -1075,12 +1086,15 @@ export default {
// A maximum of 10 subnodes can be displayed on an aggregation node. // A maximum of 10 subnodes can be displayed on an aggregation node.
const aggregationNodeLimit = 10; const aggregationNodeLimit = 10;
const idsGroup = []; const idsGroup = [];
let maxChainNum = 1;
this.allGraphData[name].children.forEach((key) => { this.allGraphData[name].children.forEach((key) => {
if (!this.allGraphData[key].grouped) { const ids = this.getAssociatedNode(key, `${name}/`);
const ids = this.getAssociatedNode(key, `${name}/`); if (ids.length) {
idsGroup.push(ids); idsGroup.push(ids);
} }
const chainNum = this.dealChainingData(key, `${name}/`);
maxChainNum = Math.max(...chainNum, maxChainNum);
}); });
const idsList = []; const idsList = [];
...@@ -1092,40 +1106,65 @@ export default { ...@@ -1092,40 +1106,65 @@ export default {
if (temp.length + idsGroup[i].length <= aggregationNodeLimit) { if (temp.length + idsGroup[i].length <= aggregationNodeLimit) {
temp = temp.concat(idsGroup[i]); temp = temp.concat(idsGroup[i]);
} else { } else {
idsList.push(temp); if (temp.length) {
temp = [].concat(idsGroup[i]); idsList.push(temp);
temp = [].concat(idsGroup[i]);
}
} }
} }
if (i === idsGroup.length - 1) { if (i === idsGroup.length - 1 && temp.length) {
idsList.push(temp); idsList.push(temp);
} }
} }
this.allGraphData[name].childIdsList = idsList; this.allGraphData[name].childIdsList = idsList;
this.allGraphData[name].index = 0; this.allGraphData[name].index = 0;
this.allGraphData[name].maxChainNum = maxChainNum;
},
dealChainingData(name, prefix) {
const node = this.allGraphData[name];
if (!node.chained) {
node.chained = true;
let temp = [];
Object.keys(node.input).forEach((key) => {
if (key.includes(prefix)) {
temp = temp.concat(this.dealChainingData(key, prefix));
}
});
if (temp.length) {
node.chainNum = [...new Set(temp.map((i) => i + 1))];
}
}
return node.chainNum;
}, },
getAssociatedNode(name, prefix) { getAssociatedNode(name, prefix) {
const node = this.allGraphData[name]; const node = this.allGraphData[name];
node.grouped = true;
let ids = []; let ids = [];
ids.push(node.name);
Object.keys(node.input).forEach((i) => { if (!node.grouped) {
if (i.startsWith(prefix)) { node.grouped = true;
if (!this.allGraphData[i].grouped) { ids.push(node.name);
const idsTemp = this.getAssociatedNode(i, prefix); Object.keys(node.input).forEach((i) => {
ids = ids.concat(idsTemp); if (i.startsWith(prefix)) {
if (!this.allGraphData[i].grouped) {
const idsTemp = this.getAssociatedNode(i, prefix);
ids = ids.concat(idsTemp);
}
} }
} });
}); Object.keys(node.output).forEach((i) => {
Object.keys(node.output).forEach((i) => { if (i.startsWith(prefix)) {
if (i.startsWith(prefix)) { if (!this.allGraphData[i].grouped) {
if (!this.allGraphData[i].grouped) { const idsTemp = this.getAssociatedNode(i, prefix);
const idsTemp = this.getAssociatedNode(i, prefix); ids = ids.concat(idsTemp);
ids = ids.concat(idsTemp); }
} }
} });
}); }
return ids; return ids;
}, },
/** /**
...@@ -1157,7 +1196,8 @@ export default { ...@@ -1157,7 +1196,8 @@ export default {
`label="${name}";class="aggregation";` + `label="${name}";class="aggregation";` +
`${ `${
node.isUnfold node.isUnfold
? `shape="polygon";width=${node.size[0]};height=${node.size[1]};fixedsize=true;` ? `shape="polygon";width=${node.size[0]};` +
`height=${node.size[1]};fixedsize=true;`
: 'shape="octagon";' : 'shape="octagon";'
}];`; }];`;
} else if (node.type === 'name_scope') { } else if (node.type === 'name_scope') {
...@@ -2285,6 +2325,8 @@ export default { ...@@ -2285,6 +2325,8 @@ export default {
node.size = []; node.size = [];
node.html = ''; node.html = '';
node.grouped = false; node.grouped = false;
node.chained = false;
node.chainNum = [1];
this.allGraphData[node.name] = node; this.allGraphData[node.name] = node;
this.allGraphData[name].children.push(node.name); this.allGraphData[name].children.push(node.name);
}); });
...@@ -2399,7 +2441,7 @@ export default { ...@@ -2399,7 +2441,7 @@ export default {
if (this.allGraphData[option.value]) { if (this.allGraphData[option.value]) {
if ( if (
d3 d3
.select(`g[id="${option.value}"],g[id="${option.value}_unfold"]`) .select(`g[id="${option.value}"], g[id="${option.value}_unfold"]`)
.size() .size()
) { ) {
// If the namespace or aggregation node is expanded, you need to close it and select // If the namespace or aggregation node is expanded, you need to close it and select
...@@ -2418,7 +2460,7 @@ export default { ...@@ -2418,7 +2460,7 @@ export default {
this.allGraphData[parentId].isUnfold this.allGraphData[parentId].isUnfold
) { ) {
const aggregationNode = this.allGraphData[parentId]; const aggregationNode = this.allGraphData[parentId];
if (aggregationNode) { if (aggregationNode && aggregationNode.childIdsList) {
for (let i = 0; i < aggregationNode.childIdsList.length; i++) { for (let i = 0; i < aggregationNode.childIdsList.length; i++) {
if (aggregationNode.childIdsList[i].includes(option.value)) { if (aggregationNode.childIdsList[i].includes(option.value)) {
aggregationNode.index = i; aggregationNode.index = i;
...@@ -2487,7 +2529,6 @@ export default { ...@@ -2487,7 +2529,6 @@ export default {
) { ) {
this.selectedNode.name = data.scope_name; this.selectedNode.name = data.scope_name;
this.querySingleNode({value: data.scope_name}); this.querySingleNode({value: data.scope_name});
this.selectNode(true);
this.$message.error(this.$t('graph.tooManyNodes')); this.$message.error(this.$t('graph.tooManyNodes'));
this.$nextTick(() => { this.$nextTick(() => {
this.loading.show = false; this.loading.show = false;
...@@ -2513,6 +2554,19 @@ export default { ...@@ -2513,6 +2554,19 @@ export default {
} }
} }
} }
if (
this.allGraphData[data.scope_name].maxChainNum >
this.maxChainNum
) {
this.selectedNode.name = data.scope_name;
this.allGraphData[data.scope_name].isUnfold = false;
this.deleteNamespace(data.scope_name);
this.$message.error(this.$t('graph.tooManyChain'));
this.$nextTick(() => {
this.loading.show = false;
});
return;
}
} }
if (data.children.scope_name) { if (data.children.scope_name) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册