create_animations improvements, progress towards removing clientresp #1432
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.
Background (as I understand it)
The
plotly.plotly.create_animations
function was introduced to support plotly.js animations because the legacy clientrest API that is used byplotly.plotly.plot
does not support frames.plotly.plotly.create_animations
uses the more recent v2 API that supports frames, but it was much more limited thanplotly.plotly.plot
. In particular is did not support uploading figures that contain inline data arrays, requiring users to manually create grids and assign grid references to their figures (See https://plot.ly/python/gapminder-example/ for example). It also did not support overwriting existing figures and it did not support creating figures in folders.This investigation was inspired by this discussion on the forums: https://community.plot.ly/t/trouble-with-converting-offline-animation-to-online/19129/2
Overview
This PR addresses these limitation mentioned above
*src
properties. Then the figure itself is uploaded. If the figure is named, then the associated grid is named'{filename}_grid'
. If the figure is not named, then the grid is named'grid_{id}'
whereid
is the url safe base64 encoding of the hash of the JSON representation of the grid. This way repeated unnamed figure creation with the same data will result in only one grid.v2.files.lookup
to check whether the figure already exists (and retrieve thefid
if it does). If it exists, update it, if not create it.v2.folders.create
to create folders before uploading figures.What's left
This implementation is nearly ready to fully replace the clientresp backend of
plotly.plotly.plot
. The only unsupported feature is thefileopt
option. See https://plot.ly/python/file-options/. Right now, the only behavior available is the defaultfileopt='overwrite'
behavior., and it doesn't look like the other options are directly supportable with the v2 API as it currently stands.Testing
There isn't currently a test suite for
create_animations
and I didn't add any additional testing in the PR. There will be a bunch of testing work to do when this implementation is used to replace theplotly.plotly.plot
backend.Questions
I've never personally used the
fileopt
argument, does anyone have opinions on whether we can deprecate this? I think my preference would be to start raising a deprecation warning forfileopt != 'overwrite'
in 3.7.0, and then remove it from the API in 4.0.0. The alternative would be to do a bit of work on the v2 API in streambed.@jackparmer @scjody @nicolaskruchten @chriddyp