jupyter / nbgrader

A system for assigning and grading notebooks

Home Page:https://nbgrader.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multiple nbgrader tabs in JupyterLab

LukasMueller187 opened this issue · comments

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?

Anyone?

@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 ?

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)?

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

const nbgraderMenu = new Menu({ commands: app.commands });

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.

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?

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.

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.

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

  • pip install nbgrader==0.8.5 in a new environment

  • move the /usr/local/share/jupyter/labextensions/nbgrader/schemas/nbgrader to /usr/local/share/jupyter/lab/schemas/nbgrader
    The menu is displayed, it seems jupyterlab can retrieve the settings from both directory.

  • pip install nbgrader==0.9.1, it updates nbgrader and jupyterlab. But the schemas in /usr/local/share/jupyter/lab/schemas/nbgrader are still there
    If I run Jupyterlab, I have both menus as you have.

  • renaming (or removing) /usr/local/share/jupyter/lab/schemas/nbgrader makes the menu disappear, but Jupyterlab starts.

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).

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.