Load data from Globus in the browser and plot with pyscript

python
Published

May 16, 2024

Globus supports a Javascript SDK which allows to authenticate against Globus Auth and then access all the Globus services, for example accessing protected data or setting up transfers between endpoints.

I think the project is really powerful because brings Globus to the browser, however it is sparsely documented, so it is really difficult to leverage its potential.

This is somehow related to my work on the CMB-S4 data portal, the idea is that on top of the static Catalog inside a Data Portal we could also provide additional services via Javascript, without the need of a backend server.

For example plotting a dataset which requires authentication.

Rick Wagner created an example that uses the Globus Javascript SDK to authenticate and retrieve a protected JSON dataset and plot it with Chart.js, see https://rpwagner.github.io/globus-sdk-javascript-ex-01/.

I expanded the example by passing the JSON dataset to PyScript (Python running in the browser) and then using pandas capabilities to parse the JSON into a DataFrame and create a Histogram on the page.

A few notes on the implementation: