-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Extract chart studio functionality, optimized imports #1476
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
Conversation
This file contains hidden or 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
Avoids writing out tmp file by create single use web server to serve the html content to the browser.
'notebook_connected+plotly_mimetype' This renderer combination will work automatically in the classic notebook, jupyterlab, nteract, vscode, and nbconvert HTML export. We use 'notebook_connected' rather than 'notebook' to avoid bloating notebook size. This comes at the cost of requiring internet connectivity, but that is a preferable trade-off to adding ~3MB to each saved notebook.
Updated tests only slightly to reflect the change in how resizing is handled now. Before there was a custom callback resize script, now we rely on the plotly.js 'responsive' config option
Use include_plotlyjs='directory' for iframe renderer.
Now there is a post_script argument to the HTML functions that allows a user to specify some custom JavaScript to run after plot creation. This can be used by plot/iplot to implement the previous save image behavior without needing to add explicit save image options to the HTML functions.
that is false by default. Now the behavior of figure display, init_notebook_mode, iplot, and plot are all backward compatible by default.
it easy to preview v4 behavior and revert to v3 behavior.
default renderer settings and default template. Get all of v4 settings with: ```python from _plotly_future_ import v4 ```
Docstrings for to_html and write_html
Conflicts: _plotly_future_/__init__.py _plotly_future_/v4.py plotly/__init__.py plotly/files.py plotly/io/_base_renderers.py plotly/io/_html.py plotly/io/_renderers.py plotly/offline/offline.py plotly/tests/test_core/test_offline/test_offline.py plotly/tests/test_io/test_renderers.py plotly/tests/test_optional/test_offline/test_offline.py plotly/tests/test_orca/test_image_renderers.py plotly/utils.py setup.py
|
@jonmmease FYI I believe this refactor broke holoviews integration (It imports plotly.offline.offline.utils, which has moved to _plotly_utils.utils). |
Contributor
Author
|
Thanks for the heads up @kmactavish. I created an issue at holoviz/holoviews#3643. |
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.
Overview
This PR is an important step towards the version 4 goal of removing all of the chart studio (i.e. cloud-service related) functionality from plotly.py, and putting it in a separate optional package.
chart studio extraction
For the time being, I've done this by creating a new top-level
chart_studiopackage next to the top-levelplotlypackage. I've moved all of the cloud-related functionality to thechart_studiopackage, following the same structure as in the current plotly package. For example, theplotly.plotlymodule was moved tochart_studio.plotly.This PR takes advantage of the
_future_plotly_system introduced in #1474 to make this refactor backward compatible.chart_studiopackage.extract_chart_studiofuture flag is set, then deprecation warnings are raised whenever thechart_studiomodules/functions are used from their legacy locations under theplotlypackage.remove_deprecationsfuture flag is set then the chart studio functions are fully removed from the plotly package and are accessible only underchart_studio. Whenremove_deprecationsis set,plotlyhas no dependency on thechart_studiopackage.Usage
To remove the chart_studio functionality from the main
plotlymodule, use theThis will further speed up imports, and will allow for testing code to make sure it will be compatible with the package structure of plotly.py version 4.
Import optimization
This PR also makes a relatively minor change to the code generation logic for
graph_objsandvalidatorthat yields an import time reduction of ~10-20% . Rather that creating a single file for each datatype and validator class, all of the classes in agraph_objorvalidatormodule are specified directly in the__init__.pyfile. This reduces the number of files significantly, which seems to yield a modest but consistent speedup while being 100% backward compatible.What's next
For version 4, the
chart_studiomodule will be published in a separate PyPI/conda package and all of the aliases tochart_studiowill be removed from theplotlyPyPI package.