Skip to content

Download and cache plot schema (or always download if no file permissions). #284

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
merged 16 commits into from
Sep 19, 2015

Conversation

theengineear
Copy link
Contributor

This PR handles getting the new plot schema downloaded/cached/backed-up within the old framework. There's no change to code usage here, just JSON handling.

Note that if enterprise doesn't have the new endpoint defined, the default one can be used. This doesn't guarantee that the plotlyjs running on the enterprise machine is in sync with the plotlyjs used to create the default though! In particular, the autotick to tickmode change on axes inside the mpl renderer may be problematic. Hopefully this will get knocked to a warning though (_deprecated) and will eventually stabilize once enterprise instances get updated versions.

Todo:

  • 🐅 for no file permissions and loaded graph reference this will get checked on circle
  • 🐅 for proper caching
  • 🐅 for working offline if it's been downloaded
  • ship a default copy of plot-schema per version, actually this is vital to keeping enterprise customers working! super important! otherwise they won't have this new url when they upgrade!
  • manually update our default schema before we close this pr.

* no need to reset the graph reference file
* send a hash along with the request to check for an update
* if the request fails *and* there’s no local reference —> error.
This is super annoying and I wasn’t able to see a simple way of getting
`six` to help us out… This is ugly but it should work.
You use `make update_default_schema` from the top-level repo file.
This means we *never* throw an error. Order of priority:

1. we successfully check with the plotly api
2. check fails, but there’s a local backup
3. check fails and no local backup. we resort to default file
@theengineear
Copy link
Contributor Author

@chriddyp @etpinard @cldougl , can I get a review on this? (pls pls pls)

@etpinard
Copy link
Contributor

Looking good.

About

ship a default copy of plot-schema per version, actually this is vital to keeping enterprise customers working! super important! otherwise they won't have this new url when they upgrade!

How often should we update the default schema?

@chriddyp
Copy link
Member

I'm not opposed to bumping the minor version number as often as plot schema changes - a robot could make PRs. That's a nice fallback in case downloading the plot schema automatically doesn't work for some reason for users, they could always just pip install plotly --upgrade and know that they'll be OK.

@theengineear
Copy link
Contributor Author

No real opinion on the upgrade frequency. A bot could load the default json dict, hash it and check if it needs updating daily, pushing to master and then uploading to PyPI on changes. I'll open up an issue to discuss on the side, #296.

sha1 = hashlib.sha1(six.b(str(graph_reference))).hexdigest()

graph_reference_url = '{}{}?sha1={}'.format(plotly_api_domain,
GRAPH_REFERENCE_PATH, sha1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, I didn't think about this. A few things to consider:

  • Is this going to break for the plotly enterprises out there that don't have v2 endpoints?
  • If we keep seperate versions of plot-schema for whichever plotly.js is being used, we'll need another version for plotly offline and whatever version of plot-schema it uses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't break enterprise solutions (more than they're already broken). They have a default schema to fall back on. This also has the deprecated stuff worked in, so it'll be allowed. A funny situation would be if the plotlyjs they are using hasn't deprecated a key and we throw a warning suggesting they use a key that actually doesn't exist yet...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chriddyp you're gonna need to refresh me on the plotly offline here 🐱. Do we have a plot schema for the plotly-offline that we can get at somewhere?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably, when plotly offline downloads (the latest) plotly.js, it can also download that version's plot-schema. This schema won't need updating, since it is locked in with the local plotly.js.

@theengineear
Copy link
Contributor Author

Anything blocking this beyond the timeout discussion?

I think it will make the update-graph-reference pr a little cleaner if I can get this merged into master and then master merged into that branch.

@cldougl
Copy link
Member

cldougl commented Sep 18, 2015

no objections here..
I merged another chart into FigureFactory yesterday so I think we'll have to add
from plotly.graph_objs import graph_objs to the distplot function

@chriddyp
Copy link
Member

boom!

@theengineear
Copy link
Contributor Author

@cldougl , yep, the merge conflict is taken care of, thanks for the reminder!

just let me know if/when it can 💃 :) @chriddyp also looking for confirmation on the 5s timeout in #284 (comment)

@chriddyp
Copy link
Member

💃

@theengineear
Copy link
Contributor Author

K, timeout added and default schema updated. mergin'

theengineear added a commit that referenced this pull request Sep 19, 2015
Download and cache plot schema (or always download if no file permissions).
@theengineear theengineear merged commit 4e644af into master Sep 19, 2015
@theengineear theengineear deleted the cache-plot-schema branch September 19, 2015 06:04
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.

4 participants