How to use the notebook.services.config.ConfigManager function in notebook

To help you get started, we’ve selected a few notebook examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jupyter-contrib / jupyter_nbextensions_configurator / tests / test_nbextensions_configurator.py View on Github external
def get_config_manager(cls):
        try:
            # single-user notebook server tests use cls.notebook for app
            return cls.notebook.config_manager
        except AttributeError:
            # jupyterhub-based tests don't (can't) have cls.notebook defined,
            # so we must construct a ConfigManager from scratch
            return ConfigManager(
                log=cls.log,
                config_dir=os.path.join(_get_config_dir(user=True), 'nbconfig')
            )
github uber / manifold / bindings / jupyter / setup.py View on Github external
def run(self):
        from notebook.nbextensions import install_nbextension
        from notebook.services.config import ConfigManager

        _develop.run(self)

        install_nbextension(EXTENSION_DIR, symlink=True,
                            overwrite=True, user=False, destination="mlvis")
        cm = ConfigManager()
        cm.update('notebook', {"load_extensions":
            {
                "mlvis/index": True,
                "mlvis/extension": True
            }
github jupyter-widgets / ipywidgets / jupyter-js-widgets-nbextension / jupyter-js-widgets-nbextension / install.py View on Github external
symlink: bool
        Symlink instead of copy (for development).
    enable: bool
        Enable the extension after installing it.
    quiet: bool
        Suppress print statements about progress.
    """
    if not quiet:
        print("Installing nbextension ...")
    staticdir = pjoin(dirname(abspath(__file__)), 'static')
    install_nbextension(staticdir, destination='widgets', user=user, symlink=symlink)
    
    if enable:
        if not quiet:
            print("Enabling the extension ...")
        cm = ConfigManager()
        cm.update('notebook', {
            "load_extensions": {
                "widgets/extension": True,
            }
        })
    if not quiet:
        print("Done.")
github jupyter / notebook / notebook / notebookapp.py View on Github external
config=True,
        help='The notebook manager class to use.'
    )
    kernel_manager_class = Type(
        default_value=MappingKernelManager,
        config=True,
        help='The kernel manager class to use.'
    )
    session_manager_class = Type(
        default_value=SessionManager,
        config=True,
        help='The session manager class to use.'
    )

    config_manager_class = Type(
        default_value=ConfigManager,
        config = True,
        help='The config manager class to use'
    )

    kernel_spec_manager = Instance(KernelSpecManager, allow_none=True)

    kernel_spec_manager_class = Type(
        default_value=KernelSpecManager,
        config=True,
        help="""
        The kernel spec manager class to use. Should be a subclass
        of `jupyter_client.kernelspec.KernelSpecManager`.

        The Api of KernelSpecManager is provisional and might change
        without warning between this version of IPython and the next stable one.
        """
github ml-tooling / ml-workspace / resources / jupyter / extensions / tooling-extension / setup.py View on Github external
def run(self):
        open_tools_widget_path = EXTENSION_NAME+"/"+OPEN_TOOLS_WIDGET
        git_tree_widget_path = EXTENSION_NAME+"/"+GIT_TREE_WIDGET
        git_notebook_widget_path = EXTENSION_NAME+"/"+GIT_NOTEBOOK_WIDGET

        # Install Python package
        install.run(self)

        # Install JavaScript extensions to ~/.local/jupyter/
        install_nbextension(EXT_DIR, overwrite=True, user=True)

        # Activate the JS extensions on the notebook, tree, and edit screens
        js_cm = ConfigManager()
        js_cm.update('tree', {"load_extensions": {open_tools_widget_path: True}})
        js_cm.update('notebook', {"load_extensions": {open_tools_widget_path: True}})
        js_cm.update('edit', {"load_extensions": {open_tools_widget_path: True}})

        js_cm.update('notebook', {"load_extensions": {git_notebook_widget_path: True}})
        js_cm.update('tree', {"load_extensions": {git_tree_widget_path: True}})

        # Activate the Python server extension
        server_extension_name = EXTENSION_NAME+"."+HANDLER_NAME

        jupyter_config_file = os.path.join(jupyter_config_dir(), "jupyter_notebook_config.json")
        if not os.path.isfile(jupyter_config_file):
            with open(jupyter_config_file, "w") as jsonFile:
                initial_data = {
                    "NotebookApp":{
                        "nbserver_extensions": {},
github rmcgibbo / jupyter-emacskeys / basesetup.py View on Github external
user_ = not _is_root()

            try:
                # IPython/Jupyter 4.0
                from notebook.nbextensions import install_nbextension
                from notebook.services.config import ConfigManager
            except ImportError:
                # Pre-schism
                from IPython.html.nbextensions import install_nbextension
                from IPython.html.services.config import ConfigManager

            extension_dir = self._nbextension_dir()
            install_nbextension(extension_dir, symlink=develop, user=user_)
            if enable is not None:
                print("Enabling the extension ...")
                cm = ConfigManager()
                cm.update('notebook', {"load_extensions": {enable: True}})
github Anaconda-Platform / nb_conda / jupyter_data_dir / nbserverextensions / condaenvs / condaenvs / install.py View on Github external
"load_extensions": {
                    'condaenvs/main': True
                },
            }
        )

        print("New config...")
        pprint(cm.get("tree"))

    if disable:
        if "prefix" in kwargs:
            path = join(kwargs["prefix"], "etc", "jupyter")
        else:
            path = jupyter_config_dir()

        cm = ConfigManager(config_dir=path)
        print("Disabling server component in", cm.config_dir)
        cfg = cm.get("jupyter_notebook_config")
        print("Existing config...")
        pprint(cfg)

        server_extensions = cfg["NotebookApp"]["server_extensions"]

        if "condaenvs.nbextension" in server_extensions:
            server_extensions.remove("condaenvs.nbextension")

        cm.update("jupyter_notebook_config", cfg)
        print("New config...")
        pprint(cm.get("jupyter_notebook_config"))

        cm = ConfigManager(config_dir=join(path, "nbconfig"))
        print(
github Anaconda-Platform / nbbrowserpdf / nbbrowserpdf / install.py View on Github external
print("Enabling nbbrowserpdf server component in", cm.config_dir)
        cfg = cm.get("jupyter_notebook_config")
        print("Existing config...")
        pprint(cfg)
        server_extensions = (
            cfg.setdefault("NotebookApp", {})
            .setdefault("server_extensions", [])
        )
        if "nbbrowserpdf" not in server_extensions:
            cfg["NotebookApp"]["server_extensions"] += ["nbbrowserpdf"]

        cm.update("jupyter_notebook_config", cfg)
        print("New config...")
        pprint(cm.get("jupyter_notebook_config"))

        cm = ConfigManager(config_dir=join(path, "nbconfig"))
        print(
            "Enabling nbpresent nbextension at notebook launch in",
            cm.config_dir
        )

        if not exists(cm.config_dir):
            print("Making directory", cm.config_dir)
            os.makedirs(cm.config_dir)

        cm.update(
            "notebook", {
                "load_extensions": {
                    "nbbrowserpdf/index": True
                },
github ipython / ipyparallel / ipyparallel / nbextension / install.py View on Github external
server_changed = False
    if enable and server_ext not in server_extensions:
        server_extensions.append(server_ext)
        server_changed = True
    elif (not enable) and server_ext in server_extensions:
        server_extensions.remove(server_ext)
        server_changed = True
    if server_changed:
        server.update('jupyter_notebook_config', {
            'NotebookApp': {
                'server_extensions': server_extensions,
            }
        })
    
    # frontend config (*way* easier because it's a dict)
    frontend = FrontendConfigManager()
    frontend.update('tree', {
        'load_extensions': {
            'ipyparallel/main': enable or None,
        }
github jupyter-attic / dashboards_bundlers / dashboards_bundlers / extensionapp.py View on Github external
def start(self):
        self.log.info("Activating jupyter_dashboards_bundlers JS notebook extensions")
        cm = ConfigManager(parent=self, config=self.config)
        cm.update('notebook', { 
            'jupyter_cms_bundlers': {
                'dashboards_local_deploy': {
                    'label': 'Local Dashboard',
                    'module_name': 'dashboards_bundlers.local_deploy',
                    'group': 'deploy'
                },
                'dashboards_php_download': {
                    'label': 'PHP Dashboard bundle (.zip)',
                    'module_name': 'dashboards_bundlers.php_download',
                    'group': 'download'
                },
                'dashboards_server_upload': {
                    'label': 'Dashboard on Jupyter Dashboards Server',
                    'module_name': 'dashboards_bundlers.server_upload',
                    'group': 'deploy'