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

Raise errors on individual problematic extensions when listing extension #1139

Merged
merged 3 commits into from
Dec 19, 2022
Merged
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
18 changes: 14 additions & 4 deletions jupyter_server/extension/serverextension.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Utilities for installing extensions"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import logging
import os
import sys

Expand Down Expand Up @@ -323,20 +324,29 @@ def list_server_extensions(self):
)

for option in configurations:
config_dir, ext_manager = _get_extmanager_for_context(**option)
config_dir = _get_config_dir(**option)
self.log.info(f"Config dir: {config_dir}")
for name, extension in ext_manager.extensions.items():
enabled = extension.enabled
write_dir = "jupyter_server_config.d"
config_manager = ExtensionConfigManager(
read_config_path=[config_dir],
write_config_dir=os.path.join(config_dir, write_dir),
)
jpserver_extensions = config_manager.get_jpserver_extensions()
for name, enabled in jpserver_extensions.items():
# Attempt to get extension metadata
self.log.info(f" {name} {GREEN_ENABLED if enabled else RED_DISABLED}")
try:
self.log.info(f" - Validating {name}...")
extension = ExtensionPackage(name=name, enabled=enabled)
if not extension.validate():
raise ValueError("validation failed")
version = extension.version
self.log.info(f" {name} {version} {GREEN_OK}")
except Exception as err:
self.log.warning(f" {RED_X} {err}")
exc_info = False
if int(self.log_level) <= logging.DEBUG:
exc_info = True
self.log.warning(f" {RED_X} {err}", exc_info=exc_info)
# Add a blank line between paths.
self.log.info("")

Expand Down