From 2b0c97b8473ba56d3e95b34d399c3eab5255fa0c Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Mon, 21 Sep 2020 19:09:04 +0100 Subject: [PATCH] dynamic => federated --- jupyterlab_server/config.py | 26 ++++++++++---------- jupyterlab_server/handlers.py | 2 +- jupyterlab_server/listings_handler.py | 2 +- jupyterlab_server/pytest_plugin.py | 4 +-- jupyterlab_server/settings_handler.py | 12 ++++----- jupyterlab_server/tests/test_settings_api.py | 8 +++--- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/jupyterlab_server/config.py b/jupyterlab_server/config.py index b5f9b972..5c3c5d4e 100644 --- a/jupyterlab_server/config.py +++ b/jupyterlab_server/config.py @@ -24,21 +24,21 @@ DEFAULT_TEMPLATE_PATH = osp.join(osp.dirname(__file__), 'templates') -def get_dynamic_extensions(labextensions_path): - """Get the metadata about dynamic extensions +def get_federated_extensions(labextensions_path): + """Get the metadata about federated extensions """ - dynamic_exts = dict() + federated_exts = dict() for ext_dir in labextensions_path: ext_pattern = ext_dir + '/**/package.json' for ext_path in [path for path in glob(ext_pattern, recursive=True)]: with open(ext_path) as fid: data = json.load(fid) - if data['name'] not in dynamic_exts: + if data['name'] not in federated_exts: data['ext_dir'] = ext_dir data['ext_path'] = osp.dirname(ext_path) data['is_local'] = False - dynamic_exts[data['name']] = data - return dynamic_exts + federated_exts[data['name']] = data + return federated_exts def get_static_page_config(app_settings_dir=None, logger=None): @@ -75,13 +75,13 @@ def get_page_config(labextensions_path, app_settings_dir=None, logger=None): """Get the page config for the application""" page_config = get_static_page_config(app_settings_dir=app_settings_dir, logger=logger) - # Handle dynamic extensions - extensions = page_config['dynamic_extensions'] = [] + # Handle federated extensions + extensions = page_config['federated_extensions'] = [] disabled_by_extensions_all = dict() - dynamic_exts = get_dynamic_extensions(labextensions_path) + federated_exts = get_federated_extensions(labextensions_path) - for (ext, ext_data) in dynamic_exts.items(): + for (ext, ext_data) in federated_exts.items(): if not 'jupyterlab' in ext_data or not '_build' in ext_data['jupyterlab']: logger.warn('%s is not a valid extension' % ext_data['name']) continue @@ -136,10 +136,10 @@ class LabConfig(HasTraits): app_settings_dir = Unicode('', help='The application settings directory.') extra_labextensions_path = List(Unicode(), - help="""Extra paths to look for dynamic JupyterLab extensions""" + help="""Extra paths to look for federated JupyterLab extensions""" ) - labextensions_path = List(Unicode(), help='The standard paths to look in for dynamic JupyterLab extensions') + labextensions_path = List(Unicode(), help='The standard paths to look in for federated JupyterLab extensions') templates_dir = Unicode('', help='The application templates directory.') @@ -149,7 +149,7 @@ class LabConfig(HasTraits): 'added.')) - labextensions_url = Unicode('', help='The url for dynamic JupyterLab extensions') + labextensions_url = Unicode('', help='The url for federated JupyterLab extensions') settings_url = Unicode(help='The url path of the settings handler.') diff --git a/jupyterlab_server/handlers.py b/jupyterlab_server/handlers.py index d4cabdca..cb9973a9 100755 --- a/jupyterlab_server/handlers.py +++ b/jupyterlab_server/handlers.py @@ -167,7 +167,7 @@ def add_handlers(handlers, extension_app): # Cache all or none of the files depending on the `cache_files` setting. no_cache_paths = [] if extension_app.cache_files else ['/'] - # Handle dynamic lab extensions. + # Handle federated lab extensions. labextensions_path = extension_app.extra_labextensions_path + extension_app.labextensions_path labextensions_url = ujoin(extension_app.labextensions_url, "(.*)") handlers.append( diff --git a/jupyterlab_server/listings_handler.py b/jupyterlab_server/listings_handler.py index 6a67ca74..7a53a6bc 100644 --- a/jupyterlab_server/listings_handler.py +++ b/jupyterlab_server/listings_handler.py @@ -1,4 +1,4 @@ -"""Tornado handlers for dynamic listings loading.""" +"""Tornado handlers for listing extensions.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. diff --git a/jupyterlab_server/pytest_plugin.py b/jupyterlab_server/pytest_plugin.py index 3647b3da..4fb3a544 100644 --- a/jupyterlab_server/pytest_plugin.py +++ b/jupyterlab_server/pytest_plugin.py @@ -91,9 +91,9 @@ def _make_labserver_extension_app(**kwargs): shutil.rmtree(dst) shutil.copytree(src, dst) - # Create the dynamic extensions + # Create the federated extensions for name in ['apputils-extension', 'codemirror-extension']: - target_name = name + '-dynamic' + target_name = name + '-federated' target = pjoin(str(labextensions_dir), '@jupyterlab', target_name) src = pjoin( os.path.abspath(os.path.dirname(__file__)), diff --git a/jupyterlab_server/settings_handler.py b/jupyterlab_server/settings_handler.py index 5b1991c6..52ed0217 100755 --- a/jupyterlab_server/settings_handler.py +++ b/jupyterlab_server/settings_handler.py @@ -138,7 +138,7 @@ def _list_settings(schemas_dir, settings_dir, overrides, extension='.json', labe """ settings = {} - dynamic_settings = {} + federated_settings = {} warnings = [] if not os.path.exists(schemas_dir): @@ -191,8 +191,8 @@ def _list_settings(schemas_dir, settings_dir, overrides, extension='.json', labe schema_base[:-len(extension)] # Remove file extension. ]).replace('\\', '/') # Normalize slashes. - # bail if we've already handled the highest dynamic setting - if id in dynamic_settings: + # bail if we've already handled the highest federated setting + if id in federated_settings: continue schema, version = _get_schema(schemas_dir, schema_name, overrides, labextensions_path=labextensions_path) @@ -202,14 +202,14 @@ def _list_settings(schemas_dir, settings_dir, overrides, extension='.json', labe warnings.append(user_settings.pop('warning')) # Add the plugin to the list of settings. - dynamic_settings[id] = dict( + federated_settings[id] = dict( id=id, schema=schema, version=version, **user_settings ) - settings.update(dynamic_settings) + settings.update(federated_settings) settings_list = [settings[key] for key in sorted(settings.keys(), reverse=True)] return (settings_list, warnings) @@ -293,7 +293,7 @@ def get_settings(app_settings_dir, schemas_dir, settings_dir, schema_name="", ov Settings overrides. If not provided, the overrides will be loaded from the `app_settings_dir`. Default is None. labextensions_path: list, optional - List of paths to dynamic labextensions containing their own schema files. + List of paths to federated labextensions containing their own schema files. Returns ------- diff --git a/jupyterlab_server/tests/test_settings_api.py b/jupyterlab_server/tests/test_settings_api.py index 11289bc7..f76b9d0b 100755 --- a/jupyterlab_server/tests/test_settings_api.py +++ b/jupyterlab_server/tests/test_settings_api.py @@ -24,8 +24,8 @@ async def test_get(fetch, labserverapp): assert 'raw' in res -async def test_get_dynamic(fetch, labserverapp): - id = '@jupyterlab/apputils-extension-dynamic:themes' +async def test_get_federated(fetch, labserverapp): + id = '@jupyterlab/apputils-extension-federated:themes' r = await fetch('lab', 'api', 'settings', id) assert r.code == 200 res = r.body.decode() @@ -40,9 +40,9 @@ async def test_get_bad(fetch, labserverapp): async def test_listing(fetch, labserverapp): ids = [ '@jupyterlab/apputils-extension:themes', - '@jupyterlab/apputils-extension-dynamic:themes', + '@jupyterlab/apputils-extension-federated:themes', '@jupyterlab/codemirror-extension:commands', - '@jupyterlab/codemirror-extension-dynamic:commands', + '@jupyterlab/codemirror-extension-federated:commands', '@jupyterlab/shortcuts-extension:plugin', '@jupyterlab/translation-extension:plugin', '@jupyterlab/unicode-extension:plugin'