Skip to content

Commit 7e51652

Browse files
chihuahuajart
authored andcommitted
Load new projector config when dataset changes (tensorflow#519)
Previously, when the data provider changed, a new projector config might not load because the name of the new run (string) could stay the same - indeed the name of the run is always 'proto'. This change makes it so that we load a new projector config and correspondingly update the UI when the data provider changes (even if the run name changes). Fixes tensorflow#478. This commit is coauthored by @svsgoogle and @chihuahua.
1 parent 7c81fe4 commit 7e51652

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

tensorboard/plugins/projector/vz_projector/vz-projector-data-panel.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export let DataPanelPolymer = PolymerElement({
2525
is: 'vz-projector-data-panel',
2626
properties: {
2727
selectedTensor: {type: String, observer: '_selectedTensorChanged'},
28-
selectedRun: {type: String, observer: '_selectedRunChanged'},
28+
selectedRun: String,
2929
selectedColorOptionName: {
3030
type: String,
3131
notify: true,
@@ -35,7 +35,10 @@ export let DataPanelPolymer = PolymerElement({
3535
{type: String, notify: true, observer: '_selectedLabelOptionChanged'},
3636
normalizeData: Boolean,
3737
showForceCategoricalColorsCheckbox: Boolean
38-
}
38+
},
39+
observers: [
40+
'_generateUiForNewCheckpointForRun(selectedRun)',
41+
],
3942
});
4043

4144
export class DataPanel extends DataPanelPolymer {
@@ -88,7 +91,15 @@ export class DataPanel extends DataPanelPolymer {
8891
this.runNames = runs;
8992
// Choose the first run by default.
9093
if (this.runNames.length > 0) {
91-
this.selectedRun = runs[0];
94+
if (this.selectedRun != runs[0]) {
95+
// This set operation will automatically trigger the observer.
96+
this.selectedRun = runs[0];
97+
} else {
98+
// Explicitly load the projector config. We explicitly load because
99+
// the run name stays the same, which means that the observer won't
100+
// actually be triggered by setting the selected run.
101+
this._generateUiForNewCheckpointForRun(this.selectedRun);
102+
}
92103
}
93104
});
94105
}
@@ -225,8 +236,8 @@ export class DataPanel extends DataPanelPolymer {
225236
this.selectedRun, this.getEmbeddingInfoByName(this.selectedTensor));
226237
}
227238

228-
_selectedRunChanged() {
229-
this.dataProvider.retrieveProjectorConfig(this.selectedRun, info => {
239+
_generateUiForNewCheckpointForRun(selectedRun) {
240+
this.dataProvider.retrieveProjectorConfig(selectedRun, info => {
230241
this.projectorConfig = info;
231242
let names =
232243
this.projectorConfig.embeddings.map(e => e.tensorName)

0 commit comments

Comments
 (0)