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

create_animations improvements, progress towards removing clientresp #1432

Merged
merged 11 commits into from
Feb 20, 2019

Conversation

jonmmease
Copy link
Contributor

@jonmmease jonmmease commented Feb 10, 2019

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 by plotly.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 than plotly.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

  1. When a figure contains inline data arrays, these arrays are extracted into a Grid. The grid is them uploaded and the column references are inserted into the figure's corresponding *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}' where id 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.
  2. Use v2.files.lookup to check whether the figure already exists (and retrieve the fid if it does). If it exists, update it, if not create it.
  3. Use 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 the fileopt option. See https://plot.ly/python/file-options/. Right now, the only behavior available is the default fileopt='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 the plotly.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 for fileopt != '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

@jonmmease jonmmease added this to the v3.7.0 milestone Feb 10, 2019
@bpostlethwaite
Copy link
Member

Depreciation notice on fileopt is the way to go. Thanks for this summary and suggested path forwards!

is specified with a non-default value.

This will allow us to drop this parameter and the clientresp API
in plotly.py version 4
Seems nose filters them out by default so nothing is caught
@jonmmease jonmmease merged commit ce2e1b5 into master Feb 20, 2019
@nicolaskruchten nicolaskruchten deleted the enh_227 branch June 19, 2020 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants