jupyter / nbgrader

A system for assigning and grading notebooks
https://nbgrader.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.3k stars 317 forks source link

multiple nbgrader tabs in JupyterLab #1839

Closed LukasMueller187 closed 11 months ago

LukasMueller187 commented 1 year ago

Operating system

Debian 12

nbgrader --version

0.9.1

jupyterhub --version (if used with JupyterHub)

4.0.2

jupyter notebook --version

7.0.4

jupyter lab --version

4.0.6

Expected behavior

Only one nbgrader tab in JupyterLab

Actual behavior

Multiple tabs: image

Steps to reproduce the behavior

I recently upgraded from the old versions of jupyter to the newest (namely Hub and Lab 4.x) and of course nbgrader 0.9.1. I disabled and reenabled / rebuilt jupyter lab and the nbgrader extension and packages. Disabling the extension properly removes both tabs. When re-enabling both appear again. I also removed the /usr/local/share/jupyter/labextensions/nbgrader folder and reinstalled the package.

Does someone have an idea?

LukasMueller187 commented 1 year ago

Anyone?

brichet commented 11 months ago

@LukasMueller187 do you still have the issue ?

I can't reproduce it locally.

nbgrader 0.9.x does not use schema (JSON configuration file) for the menu anymore, so I wonder if you could have some remaining schema somewhere in your environment.

Can you go in your config folders (jupyter --path for the list) if you have something like ./lab/user-settings/nbgrader and, if so, try to rename it ?

LukasMueller187 commented 11 months ago

Hi @brichet, Thanks for the response. Unfortunately there's no such folder. I can either fully disable both tabs or enable both at the same time.

Does anybody know how the tabs are created? This logic does live in the jupyterlab extension I guess? We've been using nbgrader for a while now and been moving from version to version (jupyterlab + hub), therefore I think this issue is due to some old logic / configs. Can anyone point me at where / how jupyterlab does load extensions (folder structure)?

brichet commented 11 months ago

Hey @LukasMueller187, I find how to reproduce it, and I still think it's related to schemas.

In nbgrader 0.9.x, the menu is dynamically created here https://github.com/jupyter/nbgrader/blob/543e6870a78c45e08a4785203a8c50abadcb2b53/src/index.ts#L70

In nbgrader 0.8.x, the menu was static and used the schemas https://github.com/jupyter/nbgrader/tree/0.8.x/schema. These schemas are interpreted by jupyterlab and associated to the relative plugin when it is activated. In this case, these schemas are interpreted when activating the plugins with ids:

If these files still exist in your environment they will be interpreted. In my case (using conda/mamba), the menu is duplicated if I copy these files in $CONDA_PREFIX/share/jupyter/labextensions/nbgrader/schemas/nbgrader.

LukasMueller187 commented 11 months ago

I think we are narrowing it down.

I did find the three json files in my deployment under /usr/local/share/jupyter/lab/schemas/nbgrader. However, if I do remove them they break JupyterLab (white screen, lots of errors in the console 'plugin ... failed to activate'.

I thought maybe a rebuild (jupyter lab build) does the job then, but unfortunately not. jupyter labextension list verifies that nbgrader v0.9.1 is enabled.

Sorry, it's been a long time since I've dug deep into jupyter, what am I missing? Some reference to the schemas in some other .json?

brichet commented 11 months ago

Sound strange, these files are only config files. Removing them should not break the extensions, and even less Jupyterlab itself. Can you copy paste the errors messages ? Are they only related to nbgrader extension ?

Some reference to the schemas in some other .json?

I don't think so.

LukasMueller187 commented 11 months ago

I had a typo in the path, the path is /usr/local/share/jupyter/lab/schemas/nbgrader (I corrected it above). I renamed the whole folder, resulting in white screen on jupyterlab and tons of error of the type:

Initially 404 on /user/username/lab/api/settings?1701695383437 with content

{"message": "Schema not found: /usr/local/share/jupyter/lab/schemas/nbgrader/assignment-list.json", "reason": null}

and tons of

Error: Invalid response: 404 Not Found
    o serverconnection.js:97
    list index.js:64
    list settingconnector.js:36
    activate settingsplugin.js:25
    promise index.es6.js:1850
    promise callback*activatePlugin index.es6.js:1850
    resolveRequiredService index.es6.js:1937
    n index.es6.js:1845
    activatePlugin index.es6.js:1845
    resolveOptionalService index.es6.js:1970
    o index.es6.js:1847
    activatePlugin index.es6.js:1847
    resolveOptionalService index.es6.js:1970
    o index.es6.js:1847
    activatePlugin index.es6.js:1847
    resolveRequiredService index.es6.js:1937
    n index.es6.js:1845
    activatePlugin index.es6.js:1845
    o index.es6.js:2013
    start index.es6.js:2012
    K index.out.js:608
    e bootstrap.js:97
    37559 bootstrap.js:67
    Webpack 3
index.es6.js:1973:24

and e.g.

Plugin '@jupyterlab/translation:translator' failed to activate.

edit: So maybe we were talking about wrong directories, note that in the folder you suggested (/usr/local/share/jupyter/labextensions/nbgrader) are no scheme files, and no subdirectory schemas.

brichet commented 11 months ago

I tried to reproduce your scenario (at least some steps):

I broke everything the first time by renaming /usr/local/share/jupyter/lab/schemas instead of /usr/local/share/jupyter/lab/schemas/nbgrader (just to be sure this is not you case).

LukasMueller187 commented 11 months ago

So I managed to find the issue:

I had a backup folder of nbgrader in /usr/local/share/jupyter/labextensions which was (conclusion of my experiment) included in the jupyter lab build version, which was an old / mixed version of nbgrader. This backup of the nbgrader was somehow using the schema files we were talking about and got built into the jupyter lab. So the fix was deleting the backup folder of nbgrader in /usr/local/share/jupyter/labextensions, running jupyter lab build, then removing the folder /usr/local/share/jupyter/lab/schemas.

Thank you for the help. It's getting kinda messy on our JupyterHub deployment, as we are running it since v2. I'm also getting puzzled again and again by the jupyter-(lab, notebook, extensions, hub) folders and am losing the overview on which folders/files are important for jupyter(lab) and it's build process. Is there a brief overview site? I'm getting lost in the JupyterLab doc again and again.