Skip to content

Commit f8116d8

Browse files
dsmilkovtensorflower-gardener
authored andcommitted
Fix (and cleanup) tests in TensorBoard and simplified build process.
Fixed things: - The internal testing was not testing lib/js/node-radar and components/tf-categorizer. - The external testing (gulp test) was not running any tests in lib/js/*, and also components/tf-categorizer. - Now both systems test everything. Cleaned things: - Unified the html test files for external (gulp test) and internal testing into one file. - running `wct` or `gulp test` (both commands are equivalent) runs the tests - When debugging tests, run `wct -p -l chrome` to open a persistent chrome browser, where you can tweak code and immediately refresh the browser to see the new test results. - Removed the unnecessary /// <reference path="" in ts files, since the typings are linked via tsconfig.json - Reused the <tf-tensoboard-demo> in the existing demo page (tf-tensorboard/demo/index.html) Change: 116601367
1 parent 23d7e98 commit f8116d8

29 files changed

+108
-178
lines changed

components/tf-categorizer/test/categorizerTest.ts

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="../categorizer.ts" />
1715
var assert = chai.assert;
1816

1917
module Categorizer {
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
6+
<script src="../../web-component-tester/browser.js"></script>
7+
<link rel="import" href="../../tf-imports/d3.html">
8+
</head>
9+
<body>
10+
<script src="../categorizer.js"></script>
11+
<script src="categorizerTest.js"></script>
12+
</body>
13+
</html>

components/tf-dashboard-common/urlGenerator.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="../plottable/plottable.d.ts" />
17-
1815
module TF {
1916
export module Urls {
2017
export type RunTagUrlFn = (tag: string, run: string) => string;
@@ -69,7 +66,21 @@ module TF {
6966
};
7067
};
7168

72-
export function demoRouter(dataDir: string): Router {
69+
export function demoRouter(dataDir: string,
70+
oldVersion = false): Router {
71+
if (oldVersion) {
72+
return {
73+
runs: () => dataDir + "runs.json",
74+
graph: (run) => dataDir + run + "-graph.pbtxt",
75+
scalars: (tag, run) => {
76+
return dataDir + run.split("_")[0] + ".json";
77+
},
78+
histograms: () => null,
79+
compressedHistograms: () => null,
80+
images: () => null,
81+
individualImage: () => null
82+
};
83+
}
7384
/* Retrieves static .json data generated by demo_from_server.py */
7485
function demoRoute(route) {
7586
return function(tag, run) {

components/tf-event-dashboard/dataCoordinator.ts

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="../plottable/plottable.d.ts" />
17-
1815
module TF {
1916

2017
/* The DataCoordinator generates TF.Datasets for each run/tag combination,

components/tf-event-dashboard/dataset.ts

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="../plottable/plottable.d.ts" />
17-
1815
module TF {
1916
/* An extension of Plottable.Dataset that knows how to load data from a backend.
2017
*/

components/tf-event-dashboard/tf-chart.ts

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="../plottable/plottable.d.ts" />
17-
1815
module TF {
1916
type TFDatum = [number, number, number];
2017
type tooltipMap = {[run: string]: string};

components/tf-graph-common/lib/graph.ts

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="common.ts" />
1715
module tf.graph {
1816

1917
/** Delimiter used in node names to denote namespaces. */

components/tf-graph-common/lib/hierarchy.ts

-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="graph.ts" />
17-
/// <reference path="template.ts" />
18-
1915
/**
2016
* Package for the Graph Hierarchy for TensorFlow graph.
2117
*/

components/tf-graph-common/lib/layout.ts

-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="graph.ts" />
17-
/// <reference path="render.ts" />
18-
1915
module tf.graph.layout {
2016

2117
/** Set of parameters that define the look and feel of the graph. */

components/tf-graph-common/lib/parser.ts

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="common.ts" />
1715
module tf.graph.parser {
1816

1917
/**

components/tf-graph-common/lib/render.ts

-5
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="graph.ts" />
17-
/// <reference path="hierarchy.ts" />
18-
1915
/**
2016
* Package for the Render Hierarchy for TensorFlow graph.
2117
*/
22-
2318
module tf.graph.render {
2419

2520
export type Point = {x: number, y: number};

components/tf-graph-common/lib/scene/annotation.ts

-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="../graph.ts" />
17-
/// <reference path="../render.ts" />
18-
/// <reference path="scene.ts" />
19-
/// <reference path="edge.ts" />
20-
/// <reference path="contextmenu.ts" />
21-
2215
module tf.graph.scene.annotation {
2316

2417
/**

components/tf-graph-common/lib/scene/edge.ts

-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="../graph.ts" />
17-
/// <reference path="../render.ts" />
18-
/// <reference path="scene.ts" />
19-
2015
module tf.graph.scene.edge {
2116

2217
/** Delimiter between dimensions when showing sizes of tensors. */

components/tf-graph-common/lib/scene/minimap.ts

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="../common.ts" />
17-
1815
module tf.scene {
1916

2017
/** Show minimap when the viewpoint area is less than X% of the whole area. */

components/tf-graph-common/lib/scene/node.ts

-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="../graph.ts" />
17-
/// <reference path="scene.ts" />
18-
/// <reference path="annotation.ts" />
19-
/// <reference path="contextmenu.ts" />
20-
2115
module tf.graph.scene.node {
2216

2317
/**

components/tf-graph-common/lib/scene/scene.ts

-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="../graph.ts" />
17-
/// <reference path="edge.ts" />
18-
/// <reference path="node.ts" />
19-
/// <reference path="../layout.ts" />
20-
2115
module tf.graph.scene {
2216

2317
/** Enums element class of objects in the scene */

components/tf-graph-common/lib/template.ts

-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
16-
/// <reference path="graph.ts" />
17-
/// <reference path="hierarchy.ts" />
18-
1915
module tf.graph.template {
2016

2117
/**
+7-36
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,11 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
5-
<link rel="import" href="../tf-tensorboard.html">
3+
<head>
4+
<script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
5+
<link rel="import" href="../tf-tensorboard-demo.html">
66
<link rel="stylesheet" type="text/css" href="../../../lib/css/global.css">
7-
<title>TensorBoard Demo</title>
8-
</head>
9-
<body>
10-
<base href="/">
11-
<dom-module id="x-demo">
12-
<template>
13-
<tf-tensorboard
14-
id="demo"
15-
router="[[demoRouter]]">
16-
</tf-tensorboard>
17-
</template>
18-
<script>
19-
var dataDir = "components/tf-tensorboard/demo/data/";
20-
var demoRouter = {
21-
runs: function() { return dataDir + "runs.json";},
22-
graph: function(run) {return dataDir + run + "-graph.pbtxt";},
23-
scalars: function(tag, run) {
24-
return dataDir + run.split("_")[0] + ".json";
25-
},
26-
};
27-
Polymer({
28-
is: "x-demo",
29-
properties: {
30-
demoRouter: {
31-
type: Object,
32-
value: demoRouter,
33-
},
34-
},
35-
});
36-
</script>
37-
</dom-module>
38-
<x-demo></x-demo>
39-
</body>
7+
</head>
8+
<body>
9+
<tf-tensorboard-demo old-version="true" data-dir="data/"></tf-tensorboard-demo>
10+
</body>
4011
</html>

components/tf-tensorboard/tf-tensorboard-demo.html

+16-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<tf-tensorboard
1010
id="tensorboard"
1111
router="[[_demoRouter]]"
12+
no-hash="[[noHash]]"
1213
></tf-tensorboard>
1314
<style>
1415
:host {
@@ -23,15 +24,27 @@
2324
properties: {
2425
_demoRouter: {
2526
type: Object,
26-
computed: "_makeDemoRouter(dataDir)",
27+
computed: "_makeDemoRouter(dataDir, oldVersion)",
2728
},
2829
dataDir: {
2930
type: String,
3031
value: "data",
3132
},
33+
// To use the old version of the router which can serve the
34+
// demo/data folder that is checked into the repository.
35+
oldVersion: {
36+
type: Boolean,
37+
value: false
38+
},
39+
// If true, tab switching in TensorBoard will not update
40+
// location hash. Hash update interferes with selenium tests.
41+
noHash: {
42+
type: Boolean,
43+
value: false
44+
}
3245
},
33-
_makeDemoRouter: function(dataDir) {
34-
return TF.Urls.demoRouter(dataDir);
46+
_makeDemoRouter: function(dataDir, oldVersion) {
47+
return TF.Urls.demoRouter(dataDir, oldVersion);
3548
},
3649
});
3750
</script>

components/tf-tensorboard/tf-tensorboard.html

+35-35
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
<paper-toolbar id="toolbar">
2121
<div id="toolbar-content">
2222
<div class="toolbar-title">TensorBoard</div>
23-
<paper-tabs selected="0" noink class="tabs" id="tabs">
24-
<paper-tab data-mode="events" on-click="changeMode">Events</paper-tab>
25-
<paper-tab data-mode="images" on-click="changeMode">Images</paper-tab>
26-
<paper-tab data-mode="graphs" on-click="changeMode">Graph</paper-tab>
27-
<paper-tab data-mode="histograms" on-click="changeMode">Histograms</paper-tab>
23+
<paper-tabs selected="{{modeIndex}}" noink class="tabs" id="tabs">
24+
<paper-tab data-mode="events">Events</paper-tab>
25+
<paper-tab data-mode="images">Images</paper-tab>
26+
<paper-tab data-mode="graphs">Graph</paper-tab>
27+
<paper-tab data-mode="histograms">Histograms</paper-tab>
2828
</paper-tabs>
2929
</div>
3030
</paper-toolbar>
@@ -111,14 +111,24 @@
111111
type: Object,
112112
value: TF.Urls.productionRouter(),
113113
},
114+
// Which tab is selected (events, graph, images etc).
114115
mode: {
115116
type: String,
116-
value: "events",
117+
computed: '_getModeFromIndex(modeIndex)'
117118
},
119+
// If true, tab switching in TensorBoard will not update
120+
// location hash. Hash update interferes with selenium tests.
121+
noHash: {
122+
type: Boolean,
123+
value: false
124+
}
118125
},
119-
changeMode: function(ev) {
120-
var mode = ev.target.parentElement.getAttribute('data-mode');
121-
this._changeMode(mode, true);
126+
_getModeFromIndex: function(modeIndex) {
127+
var mode = this.tabs[modeIndex];
128+
if (!this.noHash) {
129+
window.location.hash = mode;
130+
}
131+
return mode;
122132
},
123133
eventDashboard: function(mode) {
124134
return mode === "events";
@@ -132,36 +142,26 @@
132142
histogramDashboard: function(mode) {
133143
return mode === "histograms";
134144
},
135-
loadPreviousMode: function() {
136-
this._changeMode(this._getMode(), false);
137-
},
138145
ready: function() {
139-
this._changeMode(this._getMode(), true);
140-
141-
var self = this;
142-
window.addEventListener('hashchange', function(){
143-
self.loadPreviousMode();
146+
this.tabs = [].slice.call(this.querySelectorAll('paper-tab')).map(function(a) {
147+
return a.dataset.mode;
144148
});
149+
this._getModeFromHash();
150+
window.addEventListener('hashchange', function() {
151+
this._getModeFromHash();
152+
}.bind(this));
145153
},
146-
_changeMode: function(mode, isNewState) {
147-
this.mode = mode;
148-
149-
// Change the selected tab
150-
this.$.tabs.selected = this._tabs().indexOf(mode);
151-
152-
if (isNewState){
153-
window.location.hash = mode;
154-
}
155-
},
156-
_getMode: function() {
154+
_getModeFromHash: function() {
157155
// Return the mode as it is stored in the hash.
158-
// If no mode can be found, default to the first tab.
159-
var hash = window.location.hash;
160-
return hash.length > 0 ? hash.slice(1, hash.length) : this._tabs()[0];
161-
},
162-
_tabs: function() {
163-
var elts = Array.prototype.slice.call(this.querySelectorAll('paper-tab'));
164-
return elts.map(function(elt){ return elt.getAttribute('data-mode')});
156+
var tabName = window.location.hash.trim().slice(1);
157+
var modeIndex = this.tabs.indexOf(tabName);
158+
if (modeIndex == -1 && this.modeIndex == null) {
159+
// Selecting the first tab as default.
160+
this.set('modeIndex', 0);
161+
}
162+
if (modeIndex != -1 && modeIndex != this.modeIndex) {
163+
this.set('modeIndex', modeIndex);
164+
}
165165
},
166166
});
167167
</script>

0 commit comments

Comments
 (0)