Jupyter update custom extensions when modifying YAML file

109 Views Asked by At

I'm working on an extension for Jupyter (not JupyterLab), and I'm having issues refreshing its YAML file. When I modify it (for example, adding a parameter), I update the extension with jupyter nbextension enable test/main, but after that, Jupyter.notebook.config.data doesn't show the new parameter I've added in the YAML file.

What do I do wrong?

Here's a complete example: config.yaml:

Type: Jupyter Notebook Extension
Compatibility: 4.x, 5.x
Name: Test extension
Main: main.js
Link: README.md
Parameters:
- name: test.my_int
  description: My int
  input_type: number
  min: 0
  step: 50
  default: 250

main.js

define([
    'base/js/namespace'
], function(Jupyter) {
    "use strict";
    
    // defaults, overridden by server's config
    var options = {
        my_int: 250
    };
    
    function load_jupyter_extension() {
        Jupyter.notebook.config.loaded.then(function on_config_loaded () {
            console.log(Jupyter.notebook.config.data.test.my_int)
            $.extend(options, Jupyter.notebook.config.data.test);
        }, function on_config_load_error (reason) {
            console.warn('Using defaults after error loading config:', reason);
        })
    }

    return {
        load_jupyter_extension : load_jupyter_extension,
        load_ipython_extension : load_jupyter_extension,
    };
});

opening a Notebook displays this error in the console:

Uncaught (in promise) TypeError: Jupyter.notebook.config.data.test is undefined

1

There are 1 best solutions below

0
On BEST ANSWER

I solved the problem by deleting C:\Users\XXX\.jupyter\nbconfig\notebook.json which, for some reason, didn't refresh. restarting Jupyter after that regenerated it. I don't know why this happened, nor if it will happen again. If anyone has an idea about that...