-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add Kaleido image export support #2613
Conversation
As of This brings Kaleido to feature parity with Orca, which would make it more feasible to do a complete Orca to Kaleido switchover in a version 5. |
How about we add a new |
Would it be possible that |
@emmanuelle I'm not sure I understand what you mean. Are you talking about auto-generating the docstrings? We used to do this, but I removed it during the import optimization work because there was a non-trivial import delay. |
This works for |
Ok, I removed the future flag and added an |
Don't auto-start orca when image renderer is activated because now we might not end up using orca.
resulting bytes are reasonable
@nicolaskruchten and @emmanuelle this is ready for another review. I removed the future flag, added an For testing, I took a different approach than with orca. I'm basically just using mocks to make sure that the |
The The |
The 3.7 orca test failure is logged as #2618 and I should get to it this week :) |
Thanks for adding the I think I'm ok with that though... thoughts? |
Are you planning on updating the docs in this PR as well? I think I'd like that if possible, including changes to the README and getting-started.md please :) |
I think I'd be fine bringing the future flag back to control the default. But when would you picture changing the default, not till a v5? Yeah, I'll do the docs and README. So far I've held off because I wasn't sure how much to present Kaleido as experimental with Orca as stable, vs Kaleido as recommended and Orca as legacy. |
I'm not dead-set on adding the future flag... just wanted to bring up/discuss this outside chance of some future where someone is annoyed about this. I think I'm OK with running this risk. |
I updated the README and image export documentation to recommend Kaleido, while still describing how to use orca. Note that the documentation for installing Kaleido using conda is dependent on the acceptance of conda-forge/staged-recipes#12093 into conda-forge. I'll merge in the dendrogram fix as soon as #2627 is merged, but otherwise this is ready for review. |
…available on conda-forge initially
@nicholas-esterer @emmanuelle @nicholas-esterer Tests are passing now and this is ready for re-review. |
README.md
Outdated
|
||
### Static Image Export with Orca | ||
|
||
While Kaleido is now the recommended approach, image export can also be supported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would mention that Orca is the older, harder to install option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update in 00987c0
doc/python/orca-management.md
Outdated
@@ -34,13 +34,65 @@ jupyter: | |||
--- | |||
|
|||
### Overview | |||
This section covers the lower-level details of how plotly.py uses orca to perform static image generation. Please refer to the [Static Image Export](/python/static-image-export/) section for general information on creating static images from plotly.py figures. | |||
This section covers the lower-level details of how plotly.py can use orca to perform static image generation. Please refer to the [Static Image Export](/python/static-image-export/) section for general information on creating static images from plotly.py figures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a section above this saying "Orca is no longer the recommended way to do static export, and we now recommend Kaleido" with a link back to the static image export page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update in a25f5b2
doc/python/static-image-export.md
Outdated
##### conda | ||
Using the [conda](https://conda.io/docs/) package manager, you can install these dependencies in a single command: | ||
#### Install Dependencies (Kaleido) | ||
Static image generation requires the [`kaleido`](https://github.com/plotly/Kaleido) package which can be installed using pip... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strictly speaking this isn't correct, it requires "either Kaleido (recommended) or Orca (deprecated)" or something like that, no? Just to avoid confusing people who already know Orca? (same comment applies in other places in this PR where we've said Kaleido is required)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not in the diffs but under ### Write Image File
only orca is referred to so maybe it these could be changed to "kaleido or orca" or "the image export system in use" or something like that. For example, in this section it says: "Orca can output figures to several raster image formats including PNG, ...".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't select it but on line 40 JEPG should be JPEG.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃 modulo the documentation feedback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some typos, otherwise very slick 👍
doc/python/static-image-export.md
Outdated
##### conda | ||
Using the [conda](https://conda.io/docs/) package manager, you can install these dependencies in a single command: | ||
#### Install Dependencies (Kaleido) | ||
Static image generation requires the [`kaleido`](https://github.com/plotly/Kaleido) package which can be installed using pip... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not in the diffs but under ### Write Image File
only orca is referred to so maybe it these could be changed to "kaleido or orca" or "the image export system in use" or something like that. For example, in this section it says: "Orca can output figures to several raster image formats including PNG, ...".
doc/python/static-image-export.md
Outdated
##### conda | ||
Using the [conda](https://conda.io/docs/) package manager, you can install these dependencies in a single command: | ||
#### Install Dependencies (Kaleido) | ||
Static image generation requires the [`kaleido`](https://github.com/plotly/Kaleido) package which can be installed using pip... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't select it but on line 40 JEPG should be JPEG.
|
||
``` | ||
$ pip install psutil requests | ||
``` | ||
<!-- #endregion --> | ||
|
||
### Create a Figure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 61 should be "Now let's create a simple scatter plot with 100 random points of varying color and size."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 70c11ac
doc/python/orca-management.md
Outdated
files.download('fig1.svg') | ||
files.download('fig1.png') | ||
``` | ||
<!-- #endregion --> | ||
|
||
### Create a Figure | ||
Now let's create a simple scatter plot with 100 random points of variying color and size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now let's create a simple scatter plot with 100 random points of variying color and size. | |
Now let's create a simple scatter plot with 100 random points of varying color and size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -207,4 +259,4 @@ In addition to the `executable` property, the `plotly.io.orca.config` object can | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 253 should be - **
default_scale**: The default image scale factor applied on image export.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 8731ecfe3402002d1eac53e74e7d7ce821b2c821
…s new and recommended
Co-authored-by: Nicolas Kruchten <[email protected]>
Co-authored-by: NickE <[email protected]>
Co-authored-by: NickE <[email protected]>
Thanks for the reviews @nicholas-esterer and @nicolaskruchten, updates applied. Merging! |
This PR adds preview support for performing static image export using Kaleido instead of Orca. See the Kaleido README for discussion of project motivations and how it compares to Orca. There has not yet been a stable release of Kaleido, so the API may still evolve a little.
With this PR, Kaleido support is enabled by installing the
kaleido
package from PyPI...and setting the new
engine
kwarg inplotly.io.to_image
andplotly.io.write_image
to"kaleido"
."kaleido"
is also the default value whenkaleido
is installed.TODO:
engine
kwarg to image renderers to make it possible to override default engineOriginal Approach
With this PR, Kaleido support is enabled by installing the
kaleido
package from PyPI...and importing the
kaleido_export
future flag before importing plotlyWhen Kaleido mode is enabled, the
to_image
andwrite_image
functions use Kaleido rather than Orca.There is no change in default behavior if the
kaleido_export
future flag is not importedThere are still open questions about how we will roll out the transition from Orca to Kaleido. For example, do we wait for a version 5 for the switch? Do we support both Orca and Kaleido for a time and design a mechanism to dynamically select between them? What should we do with the
plotly.io.orca
module after orca support is dropped? Should we remove it, or remap compatible options toplotly.io.kaleido
even though only a subset of the options are compatible?This PR doesn't make any assertions about how we should do that going forward except that the Kaleido approach will still be invoked using the current
plotly.io.to_image
andplotly.io.write_image
functions. I'd like to release this preview support in version 4.9.0 so we can start asking people to try it out and gathering feedback (especially when people have problems getting Orca working).