nbgallery / lab-extensions

Repo for JupyterLab NBGallery Extensions
MIT License
1 stars 2 forks source link

Configuring jupyter lab to work with nbgallery #25

Closed iekanat closed 2 years ago

iekanat commented 2 years ago

Thanks for an awesome package. We really do need better integration between nbgallery and the jupyter lab. It is so good to see this package exists to address that need.

Mine is more an issue with documentation, rather than the code.

I managed to install and enable the extension in our set up but can't get it to upload to our nb gallery server. I can see the gallery tab in the menu, it just doesn't seem to do anything.

I suspect some configuration is needed. Unfortunately the documentation is a tad sparse... Would love some tips on how to start on this.

How can I configure the extension so that it works with our nb-gallery setup? We have multiple users, so a solution that doesn't require us to write to users' home folders would be nice.

mcrutch commented 2 years ago

Yes yes, documentation is bad and it should feel bad. Is NBGALLERY_URL environment variable set in your environment? Are you authenticated to NBGallery already? Are there any errors in the developer tools of the browser? Is the pop-up window being blocked?

image

mcrutch commented 2 years ago

I am working on the documentation updates in this branch: https://github.com/nbgallery/lab-extensions/tree/documentation-updates

iekanat commented 2 years ago

Is NBGALLERY_URL environment variable set in your environment? Are you authenticated to NBGallery already? Are there any errors in the developer tools of the browser? Is the pop-up window being blocked?

yes, yes (Our authentication is handled with apache gssapi and sudo spawner.), see below. no.

Uncaught (in promise) TypeError: Failed to construct 'URL': Invalid URL at b.getGalleryLink (56.54be2436250f7ff071ad.js?v=54be2436250f7ff071ad:1:8119) at b.uploadCallback (56.54be2436250f7ff071ad.js?v=54be2436250f7ff071ad:1:5350) at execute (56.54be2436250f7ff071ad.js?v=54be2436250f7ff071ad:1:8639) at e.execute (index.es6.js:370:33) at t.triggerActiveItem (index.es6.js:6858:27) at t._evtMouseUp (index.es6.js:7205:14) at t.handleEvent (index.es6.js:7004:22)

Something interesting to note is this: When I use notebooks downloaded from nbgallery with jupyter notebook interface I can do certain things from the lab interface as it is configured.

As it is configured, if there is already a linked notebook I can do:

I can't:

In notebooks previously not linked. I can not upload to the server...

mcrutch commented 2 years ago

Ok, this gives me a hint. It thinks your NBGallery URL is malformed. What does httpx://<pathtojupyterserver>/jupyterlab_nbgallery/environment return? It should look something like this:

{"NBGALLERY_URL": "http://<nbgallerydomainname>", "NBGALLERY_CLIENT_NAME": null, "NBGALLERY_ENABLE_AUTODOWNLOAD": null}

Does that url match NBGallery? That is pulled from the environment var in the jupyter server, was the environment var set before you started the server?

As for why downloaded notebooks work, their metadata includes the URL to their own gallery that they came from so you can support multiple galleries at once, but each instance of jupyter has a "home" gallery which is where fork and upload a new notebook go to.

iekanat commented 2 years ago

Maybe I am doing something wrong but when I use browser to go to: https://<urlofourjupyterserver>/jupyterlab_nbgallery/environment

I get redirected to:

https://<urlofourjupyterserver>/hub/jupyterlab_nbgallery/environment

Then I get a 404...

I now learned jupyter has lots of moons but this is not one :D

mcrutch commented 2 years ago

Close...but no cigar If Jupyter Lab is at /hub/<user>/lab or something similar you would look at /hub/<user>/jupyterlab_nbgallery_environment

iekanat commented 2 years ago

Very weird, I get nulls

{"NBGALLERY_URL": null, "NBGALLERY_CLIENT_NAME": null, "NBGALLERY_ENABLE_AUTODOWNLOAD": null}

I defined the NBGALLERY_URL in /etc/default/jupyterhub

JUPYTERHUB_SINGLEUSER_APP='notebook.notebookapp.NotebookApp'
NBGALLERY_URL='https://nbgallery.<companyurl>/'

I also noticed that if I don't specify JUPYTERHUB_SINGLEUSER_APP I don't get the gallery at all.

mcrutch commented 2 years ago

Yeah, somehow that isn't getting through and that is your problem. The jupyter classic extensions could also pull it in through a config file and I never went back and fixed the lab ones to do that (I never worked on the classic extensions so I didn't realize that when I was implementing the lab ones)

iekanat commented 2 years ago

Thanks for taking the time, I will try debugging a bit more.

mcrutch commented 2 years ago

/etc/default/jupyterhub might only define it for JupyterHub's environment, not each instance of Jupyter.

mcrutch commented 2 years ago

https://jupyterhub.readthedocs.io/en/stable/api/spawner.html#jupyterhub.spawner.Spawner.environment <--- Possibly appropriate

iekanat commented 2 years ago

That was very helpful actually, now I get the nbgallery url in the environment. There is still some issues I need to iron out but I am grateful for your help.

One thing that perplexes me is when I comment out JUPYTERHUB_SINGLEUSER_APP='notebook.notebookapp.NotebookApp' from /etc/default/jupyterhub I don't get any extensions anymore. Do you have any insights on that?

iekanat commented 2 years ago

Managed to get it to work by setting c.LocalProcessSpawner to = '/lab' and keeping the Singe User App bit.

Thanks for your help. Is there anything I can do to help your documentation?

mcrutch commented 2 years ago

I know more is needed in the long run, but please feel free to comment on my pull request for now. I need to make some improvements to userpreferences soon. https://github.com/nbgallery/lab-extensions/pull/26

mcrutch commented 2 years ago

Closing this as resolved, but still plan to update the docs a bit more.