-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
core: add support for iframe loading #2318
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Summary: The two loading mechanisms are now specified in the same data object, so switching from one to the other requires only a single change. The HTTP API and the frontend are unchanged. Test Plan: Modify the scalar plugin’s `frontend_metadata` to use an ES module path: ```diff diff --git a/tensorboard/plugins/scalar/scalars_plugin.py b/tensorboard/plugins/scalar/scalars_plugin.py index 1b864a74..2e06c86a 100644 --- a/tensorboard/plugins/scalar/scalars_plugin.py +++ b/tensorboard/plugins/scalar/scalars_plugin.py @@ -85,7 +85,8 @@ class ScalarsPlugin(base_plugin.TBPlugin): def frontend_metadata(self): return super(ScalarsPlugin, self).frontend_metadata()._replace( - element_name='tf-scalar-dashboard', + #element_name='tf-scalar-dashboard', + es_module_path='/magic.js', use_data_selector=True, ) ``` Then, launch TensorBoard and note that the `plugins_listing` response contains the right values for both the scalar and image plugins. wchargin-branch: es-module-metadata
wchargin-source: 0a7e48329acba4b58ab9223e6b9ad7dbea98aff8 wchargin-branch: es-module-metadata
Summary: We create a same-origin iframe and add to it a `<script>` element that dynamically imports the plugin entry point and invokes its `render`er. For now, the plugin frame has no way to communicate with the host. In the future, we’d like to be able to (e.g.) send “reload” signals from host to plugin, and enable the plugin to query the host for global state like the run selection. Test Plan: ![Screenshot of hacked up scalars plugin](https://user-images.githubusercontent.com/4317806/58985670-c1531a00-8790-11e9-9b10-3fbe293c3c2d.png) wchargin-source: c0e843435b5ea0ac3bf8740fc3f6eaa2a28f12dc wchargin-branch: iframe-loading
@stephanwlee: Does this approach seem reasonable to you? |
wchargin-source: 68b0d5da9260743d18c6ac80ef9144b1fb927fd8 wchargin-branch: iframe-loading
This is what I had in mind. |
Lovely. I’ll fix it up, then. |
wchargin-source: e4b77d9ea58d999f62d8f36a36e8987c69a5f6ed wchargin-branch: iframe-loading
wchargin
changed the title
DO NOT SUBMIT: iframe loading proof of concept
core: add support for iframe loading
Jun 5, 2019
stephanwlee
approved these changes
Jun 5, 2019
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
We create a same-origin iframe and add to it a
<script>
element thatdynamically imports the plugin entry point and invokes its
render
er.For now, the plugin frame has no way to communicate with the host. In
the future, we’d like to be able to (e.g.) send “reload” signals from
host to plugin, and enable the plugin to query the host for global state
like the run selection.
Test Plan:
Cannibalize an existing plugin to provide an ES module entry point:
Then verify that the plugin renders properly:
Also check that the reload button does not affect it (nor raise a
console error), and that switching among dashboards does not restamp the
iframe.
wchargin-branch: iframe-loading