Skip to content

[Debugger Plugin]: Add spinners for the debugger page #792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tensorboard/plugins/debugger/tf_debugger_dashboard/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ts_web_library(
"@org_polymer_paper_input",
"@org_polymer_paper_item",
"@org_polymer_paper_menu",
"@org_polymer_paper_progress",
"@org_polymer_paper_slider",
"@org_polymer_paper_spinner",
"@org_polymer_paper_styles",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<link rel="import" href="../paper-input/paper-textarea.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-menu/paper-menu.html">
<link rel="import" href="../paper-progress/paper-progress.html">
<link rel="import" href="../paper-spinner/paper-spinner-lite.html">
<link rel="import" href="../paper-toast/paper-toast.html">
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../tf-backend/tf-backend.html">
Expand Down Expand Up @@ -99,7 +101,7 @@ <h2>Continue...</h2>
out-graph-hierarchy="{{graphHierarchy}}"
out-graph="{{graph}}"
out-stats="{{stats}}"
progress="{{_progress}}"
progress="{{_graphProgress}}"
></tf-graph-loader>
</div>
</div>
Expand All @@ -124,18 +126,15 @@ <h2>Continue...</h2>
</template>
</paper-menu>
</paper-dropdown-menu>
<paper-spinner-lite class="spinner" id="top-right-spinner"></paper-spinner-lite>
<paper-progress id="top-right-progress-bar" value="0"></paper-progress>
<template is="dom-if" if="[[_isTopRightRuntimeGraphsActive]]">
<div id="graph-header">
<span id="runtime-graph-label">
Runtime Graphs
</span>
</div>
<div id="graph-container">
<tf-graph id="graph"
graph-hierarchy="[[graphHierarchy]]"
basic-graph="[[graph]]"
stats="[[stats]]"
progress="[[_progress]]"
progress="{{_graphProgress}}"
color-by="structure"
color-by-params="{{colorByParams}}"
render-hierarchy="{{_renderHierarchy}}"
Expand Down Expand Up @@ -209,6 +208,11 @@ <h2>Continue...</h2>
width: 350px;
display: inline-block;
}
#top-right-progress-bar {
width: 100%;
display: inline-block;
vertical-align: middle;
}
.line-item {
display: block;
padding-top: 5px;
Expand All @@ -230,6 +234,11 @@ <h2>Continue...</h2>
min-width: 150px;
border: 1px solid #d4d4d4;
}
.spinner {
width: 20px;
height: 20px;
vertical-align: middle;
}
.node-entries {
height: 66%;
overflow: auto;
Expand Down Expand Up @@ -390,6 +399,10 @@ <h2>Continue...</h2>
value: -1,
},

_graphProgress: {
type: Object,
},

_requestManager: {
type: Object,
value: () => new tf_backend.RequestManager(50),
Expand All @@ -398,6 +411,7 @@ <h2>Continue...</h2>

observers: [
"_onActiveRuntimeGraphDeviceNameChange(_activeRuntimeGraphDeviceName)",
"_graphProgressUpdated(_graphProgress)",
],

ready() {
Expand Down Expand Up @@ -484,6 +498,7 @@ <h2>Continue...</h2>

this._maybeUpdateTensorValueViews(
tensorName, responseData['debug_op']);
this._setTopRightSpinnerState(false);
} else {
console.error(
'Invalid long-polling response type: ', responseType);
Expand Down Expand Up @@ -734,6 +749,7 @@ <h2>Continue...</h2>
if (this._activeSessionRunKey == null) {
return;
}
this._setTopRightSpinnerState(true);

// First, check to see if any new device GraphDef(s) have arrived and if
// so, retrieve them.
Expand Down Expand Up @@ -788,6 +804,7 @@ <h2>Continue...</h2>
this._continueToType = '';
this._continueToTarget = '';
this._continueToCounterTarget = -1;
this._setTopRightSpinnerState(false);
},

_topRightSelectedChanged(topRightSelected) {
Expand Down Expand Up @@ -836,6 +853,28 @@ <h2>Continue...</h2>
console.log('Breakpoint set_state response: ', response);
});
},

_graphProgressUpdated(progress) {
const topRightProgressBar = this.$$('#top-right-progress-bar');
if (this._latestSessionRun == null) {
// No Session.run() has connected yet. Do not show the spinner(s) or
// the progress bar(s).
topRightProgressBar.setAttribute('value', 0);
this._setTopRightSpinnerState(false);
} else {
topRightProgressBar.setAttribute('value', progress.value);
this._setTopRightSpinnerState(progress.value < 100);
}
},

_setTopRightSpinnerState(isActive) {
const topRightSpinner = this.$$('#top-right-spinner');
if (isActive) {
topRightSpinner.setAttribute('active', true);
} else {
topRightSpinner.removeAttribute('active');
}
}
});

tf_tensorboard.registerDashboard({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-spinner/paper-spinner-lite.html">
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../tf-imports/lodash.html">

Expand Down Expand Up @@ -47,6 +48,12 @@
value="{{_filterInput}}"
></paper-input>
</div>
<paper-spinner-lite
active
class="spinner"
id="loading-spinner"
hidden="[[!_isLoading]]">
</paper-spinner-lite>
<div id="selector-hierarchy">
</div>
<style>
Expand Down Expand Up @@ -95,6 +102,12 @@
padding: 10px 0;
}

:host .spinner {
width: 20px;
height: 20px;
vertical-align: middle;
}

:host #filter-mode {
width: 100px;
display: inline-block;
Expand Down Expand Up @@ -167,9 +180,14 @@
value: '',
notify: true,
},

_isLoading: {
type: Boolean,
value: false,
},
},
observers: [
"_renderHierarchy(_watchHierarchy, debugWatchChange)",
"_renderHierarchyWithTimeout(_watchHierarchy, debugWatchChange)",
"_handleForceNodeExpansion(forceExpansionNodeName)",
],
_computeWatchHierarchy(debugWatches, debugWatchChange, filterMode, filterInput) {
Expand Down Expand Up @@ -218,10 +236,17 @@
}
},

_renderHierarchyWithTimeout(watchHierarchy, debugWatchChange, filterMode, filterInput) {
this._clearSelectorHierarchy();
this.set('_isLoading', true);
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe

this.async(() => {
  this._renderHierarchy(watchHierarchy, debugWatchChange, filterMode, filterInput);
});

works here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per offline discussion, setTimeout is correct here. The purpose is to let the spinner DOM update by pausing for a few milliseconds fist.

this._renderHierarchy(watchHierarchy, debugWatchChange, filterMode, filterInput);
}, 10);
},

_renderHierarchy(watchHierarchy, debugWatchChange, filterMode, filterInput) {
this.set('_levelName2Container', {});
this.set('_levelName2Node', {});
this._clearSelectorHierarchy();

const dom = this._renderLevel(null, null, watchHierarchy, debugWatchChange);

Expand Down Expand Up @@ -255,6 +280,7 @@

// Append the hierarchy to the DOM.
Polymer.dom(this.$$('#selector-hierarchy')).appendChild(dom);
this.set('_isLoading', false);
},

_renderLevel(levelName, parentLevelName, levelObject, debugWatchChange) {
Expand Down