sbailey / surveyqa

DESI Survey QA Dashboard
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

enable viewing plots even with no internet #49

Open sbailey opened 5 years ago

sbailey commented 5 years ago

We have an operational requirement that everything at the telescope can work, even if it is cut off from the internet to the outside world. This currently isn't the case with our plots because they load bokeh from https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.js (and similar links for bokeh tables and .css files).

Two pieces:

  1. When generating html pages, check if we already have those files in the output directory. If not, fetch them from cdn.pydata.org. OK to use the external "requests" library instead of the lower-level "http.client" library.
  2. Update the html output to fall back to the local copy if it can't fetch the standard copy

See https://weblogs.asp.net/jongalloway/using-cdn-hosted-jquery-with-a-local-fall-back-copy for a discussion of how to fall back to a local copy. It basically tries to load from the external server, checks if it got anything, and if not it loads from the local source (which you have pre-cached via (1)).

The reason for pre-caching in (1) instead of directly including the bokeh*.js files in our repo is that we want to support users having slightly different versions of the bokeh library and we have to keep those in sync. i.e. whoever is generating the html pages has a particular version of bokeh, and the html has to point to the matching version of the .js library.