How to use the jupyterlab.labapp.LabApp function in jupyterlab

To help you get started, we’ve selected a few jupyterlab 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 jupyterlab / jupyterlab / jupyterlab / browser_check.py View on Github external
IOLoop.current().add_future(future, finished)


def run_browser(url):
    """Run the browser test and return an exit code.
    """
    target = osp.join(get_app_dir(), 'browser_test')
    if not osp.exists(osp.join(target, 'node_modules')):
        os.makedirs(target)
        subprocess.call(["jlpm"], cwd=target)
        subprocess.call(["jlpm", "add", "puppeteer"], cwd=target)
    shutil.copy(osp.join(here, 'chrome-test.js'), osp.join(target, 'chrome-test.js'))
    return subprocess.check_call(["node", "chrome-test.js", url], cwd=target)


class BrowserApp(LabApp):
    """An app the launches JupyterLab and waits for it to start up, checking for
    JS console errors, JS errors, and Python logged errors.
    """
    open_browser = Bool(False)
    base_url = '/foo/'
    ip = '127.0.0.1'
    flags = test_flags
    aliases = test_aliases
    test_browser = True

    def start(self):
        web_app = self.web_app
        web_app.settings.setdefault('page_config_data', dict())
        web_app.settings['page_config_data']['browserTest'] = True
        web_app.settings['page_config_data']['buildAvailable'] = False
        run_test(self, run_browser if self.test_browser else lambda url: 0)
github jupyterlab / jupyterlab / jupyterlab / main.py View on Github external
print('    ' + path)
            return
        if args.describe:
            description = 'unknown'
            try:
                cwd = os.path.dirname(os.path.dirname(__file__))
                description = check_output(['git', 'describe'], cwd=cwd)
                description = description.decode('utf8').strip()
            except Exception:
                pass
            print(description)
            return

    if subcommand == 'launch':
        sys.argv = sys.argv[1:]
        LabApp.launch_instance()
    elif subcommand == 'install_extension':
        [install_extension(arg) for arg in args]
    elif subcommand == 'list_extensions':
        [print(ext) for ext in list_extensions()]
    elif subcommand == 'uninstall_extension':
        [uninstall_extension(arg) for arg in args]
    elif subcommand == 'build':
        build()
    else:
        print('unknown subcommand "%s"' % subcommand)
        sys.exit(1)
github jupyterlab / jupyterlab / jupyterlab / labapp.py View on Github external
def init_server_extensions(self):
        """Load any extensions specified by config.

        Import the module, then call the load_jupyter_server_extension function,
        if one exists.

        If the JupyterLab server extension is not enabled, it will
        be manually loaded with a warning.

        The extension API is experimental, and may change in future releases.
        """
        super(LabApp, self).init_server_extensions()
        msg = 'JupyterLab server extension not enabled, manually loading...'
        if not self.nbserver_extensions.get('jupyterlab', False):
            self.log.warn(msg)
            load_jupyter_server_extension(self)
github yuvipanda / simplest-notebook / jupyterlab / labapp.py View on Github external
def init_server_extensions(self):
        """Load any extensions specified by config.

        Import the module, then call the load_jupyter_server_extension function,
        if one exists.

        If the JupyterLab server extension is not enabled, it will
        be manually loaded with a warning.

        The extension API is experimental, and may change in future releases.
        """
        super(LabApp, self).init_server_extensions()
        msg = 'JupyterLab server extension not enabled, manually loading...'
        if not self.nbserver_extensions.get('jupyterlab', False):
            self.log.warn(msg)
            load_jupyter_server_extension(self)
github jupyterlab / jupyterlab / jupyterlab / labapp.py View on Github external
be manually loaded with a warning.

        The extension API is experimental, and may change in future releases.
        """
        super(LabApp, self).init_server_extensions()
        msg = 'JupyterLab server extension not enabled, manually loading...'
        if not self.nbserver_extensions.get('jupyterlab', False):
            self.log.warn(msg)
            load_jupyter_server_extension(self)


#-----------------------------------------------------------------------------
# Main entry point
#-----------------------------------------------------------------------------

main = launch_new_instance = LabApp.launch_instance

if __name__ == '__main__':
    main()
github jupyterlab / jupyterlab / jupyterlab / labhubapp.py View on Github external
import os

from traitlets import default

from .labapp import LabApp

try:
    from jupyterhub.singleuser import SingleUserNotebookApp
except ImportError:
    SingleUserLabApp = None
    raise ImportError('You must have jupyterhub installed for this to work.')
else:
    class SingleUserLabApp(SingleUserNotebookApp, LabApp):

        @default("default_url")
        def _default_url(self):
            """when using jupyter-labhub, jupyterlab is default ui"""
            return "/lab"

        def init_webapp(self, *args, **kwargs):
            super().init_webapp(*args, **kwargs)
            settings = self.web_app.settings
            if 'page_config_data' not in settings:
                settings['page_config_data'] = {}
            settings['page_config_data']['hub_prefix'] = self.hub_prefix
            settings['page_config_data']['hub_host'] = self.hub_host
            settings['page_config_data']['hub_user'] = self.user
            api_token = os.getenv('JUPYTERHUB_API_TOKEN')
            if not api_token:
github jupyterlab / jupyterlab-data-explorer / jupyterlab / labhubapp.py View on Github external
import os

from traitlets import default

from .labapp import LabApp

try:
    from jupyterhub.singleuser import SingleUserNotebookApp
except ImportError:
    SingleUserLabApp = None
    raise ImportError('You must have jupyterhub installed for this to work.')
else:
    class SingleUserLabApp(SingleUserNotebookApp, LabApp):

        @default("default_url")
        def _default_url(self):
            """when using jupyter-labhub, jupyterlab is default ui"""
            return "/lab"

        def init_webapp(self, *args, **kwargs):
            super().init_webapp(*args, **kwargs)
            settings = self.web_app.settings
            if 'page_config_data' not in settings:
                settings['page_config_data'] = {}
            settings['page_config_data']['hub_prefix'] = self.hub_prefix
            settings['page_config_data']['hub_host'] = self.hub_host
            settings['page_config_data']['hub_user'] = self.user
            api_token = os.getenv('JUPYTERHUB_API_TOKEN')
            if not api_token:
github yuvipanda / simplest-notebook / jupyterlab / labapp.py View on Github external
be manually loaded with a warning.

        The extension API is experimental, and may change in future releases.
        """
        super(LabApp, self).init_server_extensions()
        msg = 'JupyterLab server extension not enabled, manually loading...'
        if not self.nbserver_extensions.get('jupyterlab', False):
            self.log.warn(msg)
            load_jupyter_server_extension(self)


#-----------------------------------------------------------------------------
# Main entry point
#-----------------------------------------------------------------------------

main = launch_new_instance = LabApp.launch_instance