perspective icon indicating copy to clipboard operation
perspective copied to clipboard

Perspective 1.0.2 and above does not work in Voila

Open moiney opened this issue 4 years ago • 12 comments

Bug Report

Steps to Reproduce:

  1. Open a Jupyter notebook that uses PerspectiveWidget in Jupyterlab, where it renders correctly.
  2. Render the same notebook using Voila.

Expected Result:

Working PerspectiveWidget instances.

Actual Result:

PerspectiveWidget can not be registered in Voila. image

Environment:

Perspective > 1.0.1, Any OS, Voila 0.3.3 (same version for preview)

Additional Context:

Perspective Jupyterlab is now bundled as an ECMAScript module, and can not be loaded through requireJs into Voila. This is related to #1611

moiney avatar Mar 21 '22 17:03 moiney

@finos/perspective-jupyterlab is not bundled as an ECMAScript module - it uses the esbuild "esm" format but this is an implementation detail as the bundle contains no import nor export statements.

From the error screenshot, it looks like Voila is trying to load the plugin from CDN and using the wrong path (dist vs dist/umd as per the package.json main field). @timkpaine is this a Voila gotcha?

texodus avatar Mar 27 '22 19:03 texodus

https://github.com/voila-dashboards/voila/blob/main/packages/voila/src/loader.ts#L44

timkpaine avatar Mar 27 '22 19:03 timkpaine

i can probably update voila to check for the main of the package.json

timkpaine avatar Mar 27 '22 19:03 timkpaine

May be a bit more complex than that, as the general rules for module resolution are somewhat arbitrary (e.g. jsdelivr also respects a jsdelivr field when present, and newer versions introduce exports etc).

The error seems to indicate fetching from a CDN is an exception rather than the norm - would this be resolved by disting the plugin with perspective-python?

texodus avatar Mar 27 '22 19:03 texodus

If I just change the output location to dist, this will work I assume?

texodus avatar Mar 27 '22 19:03 texodus

https://github.com/finos/perspective/issues/467

timkpaine avatar Mar 27 '22 19:03 timkpaine

https://github.com/finos/perspective/issues/442

timkpaine avatar Mar 27 '22 19:03 timkpaine

original: https://github.com/finos/perspective/pull/335

timkpaine avatar Mar 27 '22 19:03 timkpaine

Not sure switching the output to a dist/index.js would solve the issue.

We can configure require for voila to fetch the asset from the valid path : requirejs.config({ paths: { '@finos/perspective-jupyterlab': 'https://cdn.jsdelivr.net/npm/@finos/[email protected]/dist/umd/perspective-jupyterlab' } });

Then we get the below error in the console. image

moiney avatar Mar 28 '22 08:03 moiney

Same problem here, Perspective is working fine through JupyterLab, but inside Voila he is trying to get dist/index.js from CDN and it's no loger available since 1.0.2 .

What I tried is to pass option enable_nbextensions=True to Voila, hoping that it could retrieve perspective-jupyterlab.js from local disk but it didn't work..

image

I can locate the file in /usr/local/share/jupyter/lab/staging/node_modules/@finos/perspective-jupyterlab/dist/umd/perspective-jupyterlab.js surely because I installed labextension (the npm part) and rebuilt jupyter, but voila doesn't seems to find it.

Anyone did find a working solution? In meanwhile I'll be stick with the 1.0.1 ...

th3darkang3l avatar Mar 31 '22 13:03 th3darkang3l

There is no workaround, we can fix the cdn location but the best solution is for me to finish the prebuilt extension which will let it find perspective on disk.

timkpaine avatar Mar 31 '22 16:03 timkpaine

Has there been any progress on this ticket?

wangkev avatar Aug 31 '22 11:08 wangkev

@timkpaine Is resolution of this issue waiting on approval of your PR for voila issue 1154?

scp871 avatar Nov 02 '22 01:11 scp871

Any updates here?

maxrausch avatar Mar 08 '23 20:03 maxrausch

should work after https://github.com/finos/perspective/pull/2136

timkpaine avatar Mar 20 '23 22:03 timkpaine