You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jupyter server extension list produces unexpected output when an extension cannot be imported.
Because ExtensionPoint raises on failed import during instantiation here, and add_extension captures and logs failure to load extensions (without context) here, extensions that cannot be imported are excluded from the extension list without any information about what extension failed to load.
Output, after adding 1/0 to jupyterlab/__init__.py, effectively removes jupyterlab from the list of configured extensions:
$ jupyter server extension list
Config dir: /Users/minrk/.jupyter
division by zero <-- detached from the extension that raised the error
Config dir: /Users/minrk/conda/etc/jupyter
jupyterlab_code_formatter enabled
- Validating jupyterlab_code_formatter...
jupyterlab_code_formatter 1.4.4 OK
nbclassic enabled
- Validating nbclassic...
nbclassic OK
voila.server_extension enabled
- Validating voila.server_extension...
voila.server_extension OK
I think one option is to defer import validation to the .validate() step, and not swallow errors. There appears to be some inconsistency about whether .validate() should raise on invalid (as expected here) or swallow errors and return True/False, as expected here.
Given the number of layers, I think it probably makes the most sense to let validation raise, because that lets the outermost caller (i.e. ListServerExtensionApp.run) wrap and re-display the error message, whereas True/False makes it hard for the error turned into False in ExtensionPoint.validate to be effectively displayed to the user in jupyter serverextension list to be fixed. log.warning in ExtensionPoint.validate might be sufficient, though.
Reproduce
install a server extension
make it not importable (e.g. by adding 1/0 to the module.py)
jupyter server extension list and look for information about the extension that's failing to load
Expected behavior
Informative error associated with the extension that failed to load; something more like
Config dir: /Users/minrk/conda/etc/jupyter
jupyterlab enabled
- Validating jupyterlab...
X jupyterlab: zero division error
Description
jupyter server extension list
produces unexpected output when an extension cannot be imported.Because ExtensionPoint raises on failed import during instantiation here, and add_extension captures and logs failure to load extensions (without context) here, extensions that cannot be imported are excluded from the extension list without any information about what extension failed to load.
Output, after adding
1/0
tojupyterlab/__init__.py
, effectively removesjupyterlab
from the list of configured extensions:I think one option is to defer import validation to the
.validate()
step, and not swallow errors. There appears to be some inconsistency about whether.validate()
should raise on invalid (as expected here) or swallow errors and return True/False, as expected here.Given the number of layers, I think it probably makes the most sense to let validation raise, because that lets the outermost caller (i.e.
ListServerExtensionApp.run
) wrap and re-display the error message, whereas True/False makes it hard for the error turned into False in ExtensionPoint.validate to be effectively displayed to the user injupyter serverextension list
to be fixed.log.warning
in ExtensionPoint.validate might be sufficient, though.Reproduce
1/0
to the module.py)jupyter server extension list
and look for information about the extension that's failing to loadExpected behavior
Informative error associated with the extension that failed to load; something more like
Context
The text was updated successfully, but these errors were encountered: