Modifying user settings - in a docker instance of Jupyterlab

For reasons not relevant here, I’m running jupyterlab in a docker instance, where /home/joyvan becomes a mount-point for the users home directory.

The base image is jupyter/minimal-notebook:2023-10-20 - which is

  • Ubuntu 22:04,
  • python 3.11.6,
  • hub 4.0.2,
  • lab 4.0.7,
  • notebook 7.0.6

Paths:

$ jupyter --paths
config:
    /home/jovyan/.jupyter
    /home/jovyan/.local/etc/jupyter
    /opt/conda/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /home/jovyan/.local/share/jupyter
    /opt/conda/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /home/jovyan/.local/share/jupyter/runtime

I wish to pre-configure various settings (resource-usage; the “check for updates” & “news” popups; LSPs, code-folding, etc) including removing the “log out”/“shut down” items from the “file menu”

I know that I can configure it using “Advanced settings” - however that stores the config in the /home/jovyan tree… which means it’s not actually pre-configured [and I can’t pre-configure: external persistent store]

For some, putting things in /etc/jupyter/lab/user-settings/ is working, but not everything - and the menu changes is one I’m just not able to change.

I know that /home/jovyan/.jupyter/lab/user-settings/@jupyterlab/mainmenu-extension/plugin.jupyterlab-settings:

{
   "menus": [
        {
            "disabled": false,
            "id": "jp-mainmenu-file",
            "items": [
                {
                    "command": "filemenu:logout",
                    "disabled": true
                },
                {
                    "command": "filemenu:shutdown",
                    "disabled": true
                }
            ]
        }
       ]
}

works.

I’ve tried /etc/jupyter/lab/user-settings/@jupyterlab/mainmenu-extension/plugin.jupyterlab-settings:

{
    "menus": [
    {
        "id": "jp-mainmenu-file",
        "items": [
               {
                    "command": "filemenu:logout",
                    "disabled": true
                },
                {
                    "command": "filemenu:shutdown",
                    "disabled": true
                }
            ]
        }
    ]
}

I’ve tried /etc/jupyter/lab/settings/overrides.json:

[
  {
    "@jupyterlab/apputils-extension:notification": {
      "fetchNews": "false"
    }
  },
  {
    "@jupyterlab/fileeditor-extension:editorConfig": {
      "autoClosingBrackets": true,
      "codeFolding": true
    }
  },
  {
    "@jupyterlab/mainmenu-extension:menus": {
      "id": "jp-mainmenu-file",
      "items": [
        {
          "command": "filemenu:logout",
          "disabled": true
        },
        {
          "command": "filemenu:shutdown",
          "disabled": true
        }
      ]
    }
  }
]

I’ve even tried /etc/jupyter/labconfig/page_config.json:

{
  "disabledExtensions": {
    "@jupyterlab/apputils-extension:announcements": true
  },
  "@jupyterlab/apputils-extension:notification": {
    "fetchNews": "false"
  },
  "@jupyterlab/fileeditor-extension:editorConfig": {
    "autoClosingBrackets": true,
    "codeFolding": true
  },
  "@jupyterlab/mainmenu-extension:menus": [
    {
      "id": "jp-mainmenu-file",
      "items": [
              {
                  "command": "filemenu:logout",
                  "disabled": true
              },
              {
                  "command": "filemenu:shutdown",
                  "disabled": true
              }
          ]
      }
  ]
}

… and none of them hide the two menu items.

There are 2 questions:

  1. Specifically, how/where do I configure the mainmenu to disable those 2 entries in 'Lab 4
  2. Is there a consistent way to configure extensions/plugins (in 'lab 4)

For overrides.json you are missing one level of settings and have a list instead of an object, it should be something like:

{
  "@jupyterlab/apputils-extension:notification": {
    "fetchNews": "false"
  },
  "@jupyterlab/mainmenu-extension:menus": {
    "menus": [
      {
        "id": "jp-mainmenu-file",
        "items": [
          {
            "command": "filemenu:logout",
            "disabled": true
          },
          {
            "command": "filemenu:shutdown",
            "disabled": true
          }
        ]
      }
    ]
  }
}
1 Like

Hmmm… that’s not working for me:

test Dockerfile:

FROM jupyter/minimal-notebook:848a82674792
USER root
COPY overrides.json /etc/jupyter/lab/settings/overrides.json
# RUN jupyter lab clean && jupyter lab build
WORKDIR $HOME
USER $NB_USER
CMD ["start-notebook.sh"]

… and overrides.json:

[
  {
    "@jupyterlab/apputils-extension:announcements": {
      "checkForUpdates": false,
      "doNotDisturbMode": false,
      "fetchNews": "false"
    }
    }
  },
  {
    "@jupyterlab/mainmenu-extension:menus": {
      "menus": [
        {
          "id": "jp-mainmenu-file",
          "items": [
            {
              "command": "filemenu:logout",
              "disabled": true
            },
            {
              "command": "filemenu:shutdown",
              "disabled": true
            }
          ]
        }
      ]
    }
  }
]

I get the “Do you want news” modal, and the menu items exist

[Further: if I put `overrides.json` in `${HOME}/.jupyter/lab/settings/`overrides.json` - it also doesn’t work as expected]

You still have the overrides wrong. It should NOT be in a list. Please look carefully at my snippet - the top level object is a mapping, not an array.

1 Like

Aha… I seem to have some effect on the menu if I put the file in /opt/conda/share/jupyter/lab/settings/overrides.json for my docker instance

Still need to figure out the the other parts

Right… here’s where I’ve got to:

  • /opt/conda/etc/jupyter/labconfig/ takes page_config.json - which purely enables/disables extensions (such as notifications & fetchNews) but does not allow configuration changes (such as removing menu items)
  • /opt/conda/share/jupyter/lab/settings/ takes overrides.json - which allows some, but not all, extensions to be configured:
    • I can remove menu items, but I can’t add code-folding to code-mirror
  • $JUPYTERLAB_SETTINGS_DIR (defaults to $HOME/.jupyter/lab/user-settings/ but can be changed) is where extensions are configured
    • there’s a complex directory named for extension system
    • there’s no heirarchy available - this appears to be the singular place for this type of configurtion
1 Like

In principle this enables all extensions to be configured. As for your code-folding in CodeMirror, you again have a mixup in the JSON structure. The plugin name is @jupyterlab/fileeditor-extension:plugin not @jupyterlab/fileeditor-extension:editorConfig. editorConfig is a nesting level:

{
  "@jupyterlab/fileeditor-extension:plugin": {
    "editorConfig": {
      "autoClosingBrackets": true,
      "codeFolding": true
    }
  }
}

should work (of course only in the text editor - as specified).

1 Like

More lightbulbs… this is really useful - thank you for the time here!

Trying to wrap my head around the general case.

So if I go to SettingsSettings EditorJSON Settings Editor and then select the item I want to change the configuration for… the System Defaults contents should list the plugin name in the comments (randomly selecting Code Completion, it gives me @jupyterlab/completer-extension:manager)

This is the value to use as the key in the overrides.json file, and the value for that key is a dictionary containing whatever parts of the defaults I want to change*

eg, staying with Code Completion, I would add the key/value pair

  "@jupyterlab/completer-extension:manager": {
    "autoCompletion": true
  }

to the overrides.json dictionary

… and that individual users can also make changes through the same configuration UI, and their changes are stored under $HOME/.jupyter/lab/user-settings/<some>/<path>/<file> - which take precidence over the config given in overrides.json

[*] accepting not all plugins will list add options in their defaults

1 Like