akaihola / jupyter_abc

This extension makes it easy to render ABC markup as graphical music notation in a Jupyter notebook.
Other
10 stars 2 forks source link

`abcjs` loading fails on Azure Notebooks #2

Open akaihola opened 6 years ago

akaihola commented 6 years ago

I'm trying to use jupyter_abc in https://jupyterabcdemo-kaiant.notebooks.azure.com/j/notebooks/jupyter_abc%20demo.ipynb

On Firefox, I see this in the Javascript console:

Loading failed for the <script> with source
“https://jupyterabcdemo-kaiant.notebooks.azure.com/nbextensions/jupyter-abc/abcjs_basic_5.1.2-min.js?v=5.5.0”.
jupyter_abc%20demo.ipynb:1

On Brave, the error is a bit more verbose:

Refused to execute script from
'https://notebooks.azure.com/nbextensions/jupyter-abc/abcjs_basic_5.1.2-min.js?v=5.5.0'
because its MIME type ('text/html') is not executable,
and strict MIME type checking is enabled.

Note that the host name is different (and wrong) on Brave.

akaihola commented 6 years ago

Maybe related to ipython-contrib/jupyter_contrib_nbextensions#527?

psychemedia commented 6 years ago

I'm failing on trying to run this extension on Azure notebooks too.

psychemedia commented 6 years ago

In my version of Chrome, error shows as failing to load resource from

Failed to load resource: the server responded with a status of 404 (Not Found) 
https://gettingstarted-ousefulinfo.notebooks.azure.com/Scripts/jupyter/5.5.0/abcjs.js?v=20180815065512

which then leads to:

Refused to execute script from
  'https://gettingstarted-ousefulinfo.notebooks.azure.com/Scripts/jupyter/5.5.0/abcjs.js?v=20180815065512' 
  because its MIME type ('') is not executable, and strict MIME type checking is enabled.

because of the 404.

There is a file at https://gettingstarted-ousefulinfo.notebooks.azure.com/nb/nbextensions/jupyter-abc/abcjs_basic_5.1.2-min.js but that's not being found. So where does the /Scripts/jupyter/5.5.0/abcjs.js come from?

The %load_ext jupyter_abc runs the following via its output cell:

    require.config(
        {paths: {abcjs: require.toUrl("nbextensions/jupyter-abc/abcjs_basic_5.1.2-min.js")},
         shim: {abcjs: {exports: 'ABCJS'}}}
    );
psychemedia commented 6 years ago

Would a workaround for now be to offer the opportunity to load the abc.js file from a CDN?

akaihola commented 6 years ago

@psychemedia, I guess Azure's version of Jupyter customizes URLs in a way that's different from just plain Jupyter.

A CDN would certainly be a work-around, but I'd like to solve this properly, hopefully with help from members of the Azure Notebooks team. It could also help them in making it easy for other extension authors to support Azure Notebooks.

andneilmsft commented 6 years ago

We'll take a look at what we might be able to do here from a Azure notebooks POV and get back to this thread.

psychemedia commented 5 years ago

I just spotted in a PR to music21 that there's a method demonstrating using a local js file, though I haven't tried it on Azure notebooks: https://github.com/cuthbertLab/music21/pull/326

rachelgshaffer commented 5 years ago

As a work around, disable "Experimental Notebooks" feature by editing your settings. We are working to fix a bug that will resolve this issue. image

psychemedia commented 5 years ago

@rachelgshaffer This still doesn't work for me in Azure notebooks? Package installs and magics run without error but no score is displayed?

rachelgshaffer commented 5 years ago

@psychemedia can you provide me a link to your library? Thanks!

psychemedia commented 5 years ago

@rachelgshaffer Example notebook here: https://notebooks.azure.com/OUsefulInfo/libraries/gettingstarted/html/4.1.0%20Music%20Notation.ipynb The abc demo is straight from the docs and appears about three quarters of the way into the notebook.