From b5562992b2a67e29d98db65e823e21285717ede0 Mon Sep 17 00:00:00 2001 From: WeiFeng-mindinsight Date: Tue, 8 Dec 2020 14:15:17 +0800 Subject: [PATCH] UI add sending state handling of debugger training --- mindinsight/ui/src/locales/zh-cn.json | 3 +- mindinsight/ui/src/mixins/debugger-mixin.vue | 37 +++++++--- .../ui/src/views/debugger/debugger.vue | 70 ++++++++++++------- 3 files changed, 75 insertions(+), 35 deletions(-) diff --git a/mindinsight/ui/src/locales/zh-cn.json b/mindinsight/ui/src/locales/zh-cn.json index 5c2af397..b83b131b 100644 --- a/mindinsight/ui/src/locales/zh-cn.json +++ b/mindinsight/ui/src/locales/zh-cn.json @@ -733,7 +733,8 @@ "inf": "张量中含有+/-INF,", "no_prev_tensor": "找不到上一个迭代的值,", "cannotCheck": "无法检查。" - } + }, + "sendingTip": "等待训练响应,请稍候。" }, "explain": { "explain": "模型解释", diff --git a/mindinsight/ui/src/mixins/debugger-mixin.vue b/mindinsight/ui/src/mixins/debugger-mixin.vue index cc03106c..7cc6efdb 100644 --- a/mindinsight/ui/src/mixins/debugger-mixin.vue +++ b/mindinsight/ui/src/mixins/debugger-mixin.vue @@ -18,7 +18,7 @@ export default { * Initialize the condition */ initCondition() { - if (this.metadata.state === 'running') { + if (this.metadata.state === this.state.running || this.metadata.state === this.state.sending) { return; } RequestService.queryConditions(this.trainId).then((res) => { @@ -471,7 +471,7 @@ export default { graphName, ); } - if (res.data.watch_point_hits && res.data.watch_point_hits.length > 0) { + if (res.data.watch_point_hits) { this.radio1 = 'hit'; this.getWatchpointHits(); } @@ -525,12 +525,31 @@ export default { (res) => { if (res.data && res.data.metadata) { const h = this.$createElement; - this.$message({ - message: h('p', null, [ - h('span', null, this.$t('debugger.backstageStatus')), - h('i', {style: 'color: teal'}, res.data.metadata.state), - ]), - }); + + if (res.data.metadata.state === this.state.sending) { + setTimeout(() => { + if (this.metadata.state === this.state.sending) { + this.$message(this.$t('debugger.sendingTip')); + } else { + const msg = { + message: h('p', null, [ + h('span', null, this.$t('debugger.backstageStatus')), + h('i', {style: 'color: teal'}, this.metadata.state), + ]), + }; + this.$message(msg); + } + }, 500); + } else { + const msg = { + message: h('p', null, [ + h('span', null, this.$t('debugger.backstageStatus')), + h('i', {style: 'color: teal'}, res.data.metadata.state), + ]), + }; + this.$message(msg); + } + this.metadata.state = res.data.metadata.state; } }, @@ -596,7 +615,7 @@ export default { * @param {Object} item watchpoint data */ deleteWatchpoint(item) { - if (!this.watchPointArr.length || this.metadata.state === 'running') { + if (!this.watchPointArr.length || this.metadata.state === this.state.running || this.metadata.state === this.state.sending) { return; } if ((item && item.id) || !item) { diff --git a/mindinsight/ui/src/views/debugger/debugger.vue b/mindinsight/ui/src/views/debugger/debugger.vue index 77b097ae..73ff7fd8 100644 --- a/mindinsight/ui/src/views/debugger/debugger.vue +++ b/mindinsight/ui/src/views/debugger/debugger.vue @@ -83,10 +83,12 @@ limitations under the License. {{ $t('public.selectAll') }} {{ $t('public.deselectAll') }}
@@ -258,21 +261,21 @@ limitations under the License. {{ $t('public.sure') }}
{{$t('debugger.continue')}} {{$t('debugger.pause')}} {{$t('debugger.terminate')}}
@@ -402,7 +405,7 @@ limitations under the License.
{{ $t('debugger.view') }} @@ -411,13 +414,14 @@ limitations under the License. class="value-tip" size="mini" type="text" - :disabled="metadata.state==='running'" + :disabled="metadata.state===state.running || metadata.state === state.sending" :title="isNaN(scope.row.value)?'':scope.row.value" @click="showTensor(scope.row,'value')"> {{ scope.row.value }} {{ $t('debugger.compareToPre') }} @@ -782,7 +786,16 @@ export default { checked: 2, noCheckbox: -1, }, + percentParams: ['zero_percentage_ge', 'range_percentage_lt', 'range_percentage_gt'], + oldState: '', treeDisabled: false, + state: { + running: 'running', + pending: 'pending', + mismatch: 'mismatch', + sending: 'sending', + waiting: 'waiting', + }, }; }, components: {debuggerTensor, tree}, @@ -794,29 +807,36 @@ export default { watch: { 'metadata.state': { handler(newValue, oldValue) { - if (newValue === 'pending' && oldValue !== undefined) { - location.reload(); - } - if (oldValue === 'pending' && newValue === 'waiting') { - this.loadNode(this.node, this.resolve); + if (newValue === this.state.mismatch) { + this.conflictFlag = true; + } else { + this.conflictFlag = false; } - if (oldValue === 'running' && newValue === 'waiting') { - this.getWatchpointHits(); + + if (newValue === this.state.pending) { + if (oldValue) { + location.reload(); + } else { + this.dialogVisible = true; + } + } else { + this.dialogVisible = false; } - if (newValue === 'running') { + if (newValue === this.state.running || newValue === this.state.sending) { this.treeDisabled = true; } else { this.treeDisabled = false; } - if (newValue === 'pending') { - this.dialogVisible = true; - } else { - this.dialogVisible = false; + if (newValue === this.state.sending && oldValue) { + this.oldState = oldValue; } - if (newValue === 'mismatch') { - this.conflictFlag = true; - } else { - this.conflictFlag = false; + + if (newValue === this.state.waiting) { + if (this.oldState === this.state.pending || oldValue === this.state.pending) { + this.loadNode(this.node, this.resolve); + } else if (this.oldState === this.state.running || oldValue === this.state.running) { + this.getWatchpointHits(); + } } }, deep: true,