Skip to content
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

Connect data-selector to tf-tensorboard #1318

Merged
merged 1 commit into from
Jul 30, 2018
Merged
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
19 changes: 15 additions & 4 deletions tensorboard/components/tf_tensorboard/tf-tensorboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h2>Settings</h2>
<div id="content-pane" class="fit">
<template is="dom-if" if="[[_isDataSelectorEnabled]]">
<div id="data-selector">
<tf-data-selector data-selection="{{_dataSelection}}">
<tf-data-selector selection="{{_dataSelection}}">
</tf-data-selector>
</div>
</template>
Expand Down Expand Up @@ -530,6 +530,8 @@ <h3>There’s no dashboard by the name of “<tt>[[_selectedDashboard]]</tt>.”
('_ensureSelectedDashboardStamped(' +
'_dashboardContainersStamped, _activeDashboards, ' +
'_selectedDashboard)'),
('_updateDataSelection(_dataSelection, _activeDashboards,' +
'_selectedDashboard)'),
],

_activeDashboardsUpdated(activeDashboards, selectedDashboard) {
Expand Down Expand Up @@ -685,11 +687,11 @@ <h3>There’s no dashboard by the name of “<tt>[[_selectedDashboard]]</tt>.”
if (container.children.length === 0) {
const component = document.createElement(dashboard.elementName);
component.id = 'dashboard'; // used in `_selectedDashboardComponent`
if (dashboard.useDataSelector) {
component.dataSelection = this._dataSelection;
}
container.appendChild(component);
}
if (dashboard.useDataSelector) {
container.firstElementChild.dataSelection = this._dataSelection;
}
this.set('_isReloadDisabled', dashboard.isReloadDisabled);
this.set('_isDataSelectorEnabled', dashboard.useDataSelector);
},
Expand All @@ -715,6 +717,15 @@ <h3>There’s no dashboard by the name of “<tt>[[_selectedDashboard]]</tt>.”
return dashboard;
},

_updateDataSelection() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just so I understand, this observer is necessary because Polymer doesn't have enough context to automatically propagate the data selection from the tf-tensorboard _dataSelection property into the stamped dashboard element binding? I wonder if there's any way to explicitly tell Polymer to do that for us....

...it looks like probably not: Polymer/polymer#1778 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, that was my intention. I technically don't need two-way binding since I don't need the upward directionality. For now, I thought, the code is clean enough as is. Let me know if you are okay with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, it's fine as is.

// The dashboard is not ready yet until it stamped the containers.
if (!this._dashboardContainersStamped) return;
const component = this._selectedDashboardComponent();
// The dashboard may not exist.
if (!component) return;
component.dataSelection = this._dataSelection;
},

ready() {
tf_globals.setUseHash(this.useHash);
this._updateSelectedDashboardFromHash();
Expand Down