mercury icon indicating copy to clipboard operation
mercury copied to clipboard

Js resource access

Open beebeed opened this issue 2 years ago • 7 comments

I am have issues in rendering ipydatagrid within your excellent mercury framework. The jupyter notebook renders the datagrid outside of mercury but when run in mercury it appears not to be able to find the .js resources.

I get the following errors

[Open Browser Console for more detailed log - Double click to close this message]
Failed to create view for 'DataGridView' from module 'ipydatagrid' with model 'DataGridModel' from module 'ipydatagrid'
TypeError: c.JupyterPhosphorPanelWidget is not a constructor
    at g._createElement (https://cdn.jsdelivr.net/npm/ipydatagrid@%5E1.1.12/dist/index.js:2:997709)

looking at the console I see the following

Failed to load resource: the server responded with a status of 404 (Not Found)
:8988/media/temp/ipydatagrid.js:1
Falling back to https://cdn.jsdelivr.net/npm/ for [ipydatagrid@^1.1.12](mailto:ipydatagrid@%5e1.1.12)

not sure how to resolve this - any suggestions?

Is it possible to make the js files static so they do not need to be downloaded?

Thanks

David

beebeed avatar Aug 31 '22 07:08 beebeed

Hi @beebeed!

Thanks for reporting the issue. Is ipydatagrid working after HTML export with nbconvert?

You can try to convert the notebook:

jupyter nbconvert --to html my-notebook.ipynb

If it works, then it should work with Mercury. FYI, the ipywidgets are not working after nbconvert and can't be used with Mercury.

Your error is very similar to this one https://github.com/bloomberg/ipydatagrid/issues/231

One more thought, maybe you can use Pandas DataFrame to display values and try to add some styling https://pandas.pydata.org/docs/user_guide/style.html

pplonski avatar Aug 31 '22 08:08 pplonski

Thanks for your quick reply @pplonski … … indeed it currently does not work with nbconvert. The odd thing is that ipydatagrid DID work in mercury before I went on holiday but now it doesn’t - I can’t figure out what has changed… any ideas? Similarly with qgrid it was working but it now doesn’t. Very odd.

beebeed avatar Aug 31 '22 10:08 beebeed

As a follow-up @pplonski I noticed there was an error before hand which relates to the source maps

DevTools failed to load source map: Could not load content for https://unpkg.com/@jupyter-widgets/html-manager@*/dist/embed-amd-render.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE I have checked the browser and it allows access to the source maps - does this point to another issue?

for your info I am using this code

from ipydatagrid import DataGrid
import numpy as np 
import pandas as pd 

df = pd.DataFrame(data=np.random.randn(5,10))
datagrid=DataGrid(df)
datagrid

I am curious of what has happened since this used to work!

many thanks

beebeed avatar Aug 31 '22 16:08 beebeed

Hi @beebeed,

I've run your example code, this is what I got: image

image

I think it is the issue with ipydatagrid.

pplonski avatar Sep 02 '22 07:09 pplonski

So same as me @pplonski, it is just odd that I did get it working but not idea how that happened and no idea why it isn’t working now. Have reverted to using itables.

I guess the issue is the use of widgets? Do you plan / is it possible to incorporate widgets into the mercury framework? Think it would add great functionality.

beebeed avatar Sep 02 '22 08:09 beebeed

@beebeed ipywidgets will not be supported in the Mercury. It has an architecture that can't support it. Sorry!

You can try to use voila - they support ipywidgets.

pplonski avatar Sep 02 '22 08:09 pplonski

@beebeed, may I ask what functionality you need from the grid/tables display? Is it just to display the data? or for exploration?

pplonski avatar Sep 02 '22 08:09 pplonski

df = pd.DataFrame(data=np.random.randn(5,10)) datagrid=DataGrid(df) datagrid

your code is showing the below message on mercury and not displaying the table: image

@pplonski is there any fix for such issue?

gmouawad avatar Jun 26 '23 19:06 gmouawad

@gmouawad I think there should be some display method available for data grid. If you don't find a way to display it please create a new issue.

pplonski avatar Jun 27 '23 07:06 pplonski