Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove listings handler #292

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions docs/source/api/handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ Module: :mod:`jupyterlab_server.handlers`
.. autofunction:: is_url


Module: :mod:`jupyterlab_server.listings_handler`
=================================================

.. automodule:: jupyterlab_server.listings_handler

.. currentmodule:: jupyterlab_server.listings_handler

.. autoclass:: ListingsHandler
:members:

.. autofunction:: fetch_listings


Module: :mod:`jupyterlab_server.settings_handler`
=================================================

Expand Down
47 changes: 3 additions & 44 deletions jupyterlab_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,74 +29,33 @@ def app_namespace(self):

app_version = Unicode("", help="The version of the application.").tag(default=__version__)

blacklist_uris = Unicode(
"", config=True, help="Deprecated, use `LabServerApp.blocked_extensions_uris`"
)

blocked_extensions_uris = Unicode(
"",
config=True,
help="""
A list of comma-separated URIs to get the blocked extensions list

.. versionchanged:: 2.0.0
`LabServerApp.blacklist_uris` renamed to `blocked_extensions_uris`
""",
)

whitelist_uris = Unicode(
"", config=True, help="Deprecated, use `LabServerApp.allowed_extensions_uris`"
)

allowed_extensions_uris = Unicode(
"",
config=True,
help="""
"A list of comma-separated URIs to get the allowed extensions list

.. versionchanged:: 2.0.0
`LabServerApp.whitetlist_uris` renamed to `allowed_extensions_uris`
A list of comma-separated URIs to get the allowed extensions list
""",
)

listings_refresh_seconds = Integer(
60 * 60, config=True, help="The interval delay in seconds to refresh the lists"
)

listings_request_options = Dict(
listings_tornado_options = Dict(
{},
config=True,
help="The optional kwargs to use for the listings HTTP requests \
as described on https://2.python-requests.org/en/v2.7.0/api/#requests.request",
as described on https://www.tornadoweb.org/en/stable/httpclient.html#tornado.httpclient.HTTPRequest",
)

_deprecated_aliases = {
"blacklist_uris": ("blocked_extensions_uris", "1.2"),
"whitelist_uris": ("allowed_extensions_uris", "1.2"),
}

# Method copied from
# https://github.com/jupyterhub/jupyterhub/blob/d1a85e53dccfc7b1dd81b0c1985d158cc6b61820/jupyterhub/auth.py#L143-L161
@observe(*list(_deprecated_aliases))
def _deprecated_trait(self, change):
"""observer for deprecated traits"""
old_attr = change.name
new_attr, version = self._deprecated_aliases.get(old_attr)
new_value = getattr(self, new_attr)
if new_value != change.new:
# only warn if different
# protects backward-compatible config from warnings
# if they set the same value under both names
self.log.warning(
"{cls}.{old} is deprecated in JupyterLab {version}, use {cls}.{new} instead".format(
cls=self.__class__.__name__,
old=old_attr,
new=new_attr,
version=version,
)
)
setattr(self, new_attr, change.new)

def initialize_templates(self):
self.static_paths = [self.static_dir]
self.template_paths = [self.templates_dir]
Expand Down
44 changes: 0 additions & 44 deletions jupyterlab_server/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from .config import LabConfig, get_page_config, recursive_update
from .licenses_handler import LicensesHandler, LicensesManager
from .listings_handler import ListingsHandler, fetch_listings
from .server import FileFindHandler, JupyterHandler
from .server import url_path_join as ujoin
from .settings_handler import SettingsHandler
Expand Down Expand Up @@ -249,49 +248,6 @@ def add_handlers(handlers, extension_app):
workspace_api_path = ujoin(extension_app.workspaces_api_url, "(?P<space_name>.+)")
handlers.append((workspace_api_path, WorkspacesHandler, workspaces_config))

# Handle local listings.

settings_config = extension_app.settings.get("config", {}).get("LabServerApp", {})
blocked_extensions_uris = settings_config.get("blocked_extensions_uris", "")
allowed_extensions_uris = settings_config.get("allowed_extensions_uris", "")

if (blocked_extensions_uris) and (allowed_extensions_uris):
warnings.warn(
"Simultaneous blocked_extensions_uris and allowed_extensions_uris is not supported. Please define only one of those."
)
import sys

sys.exit(-1)

ListingsHandler.listings_refresh_seconds = settings_config.get(
"listings_refresh_seconds", 60 * 60
)
ListingsHandler.listings_request_opts = settings_config.get("listings_request_options", {})
listings_url = ujoin(extension_app.listings_url)
listings_path = ujoin(listings_url, "(.*)")

if blocked_extensions_uris:
ListingsHandler.blocked_extensions_uris = set(blocked_extensions_uris.split(","))
if allowed_extensions_uris:
ListingsHandler.allowed_extensions_uris = set(allowed_extensions_uris.split(","))

fetch_listings(None)

if (
len(ListingsHandler.blocked_extensions_uris) > 0
or len(ListingsHandler.allowed_extensions_uris) > 0
):
from tornado import ioloop

ListingsHandler.pc = ioloop.PeriodicCallback(
lambda: fetch_listings(None),
callback_time=ListingsHandler.listings_refresh_seconds * 1000,
jitter=0.1,
)
ListingsHandler.pc.start()

handlers.append((listings_path, ListingsHandler, {}))

# Handle local themes.
if extension_app.themes_dir:
themes_url = extension_app.themes_url
Expand Down
91 changes: 0 additions & 91 deletions jupyterlab_server/listings_handler.py

This file was deleted.

33 changes: 0 additions & 33 deletions jupyterlab_server/rest-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,6 @@ info:
name: BSD-3-Clause

paths:
/lab/api/listings/%40jupyterlab/extensionmanager-extension/listings.json:
get:
summary: Get Extension Listings Specs
description: |
Gets the list of extension metadata for the application
responses:
"200":
description: The Extension Listing specs
content:
application/json:
schema:
properties:
blocked_extension_uris:
type: array
description: list of blocked extension uris
items:
type: string
allowed_extension_uris:
type: array
description: list of allowed extension uris
items:
type: string
blocked_extensions:
type: array
description: list of blocked extensions
items:
$ref: "#/components/schemas/ListEntry"
allowed_extensions:
type: array
description: list of blocked extensions
items:
$ref: "#/components/schemas/ListEntry"

/lab/api/settings/:
get:
summary: Get Settings List
Expand Down
7 changes: 0 additions & 7 deletions tests/test_listings_api.py

This file was deleted.