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

Spurious `unknown message usage_request errors #214

Open
nthiery opened this issue Sep 26, 2023 · 3 comments
Open

Spurious `unknown message usage_request errors #214

nthiery opened this issue Sep 26, 2023 · 3 comments
Labels

Comments

@nthiery
Copy link

nthiery commented Sep 26, 2023

Description

jupyter-error-messages now emits "usage_request" messages. However not all
kernels support them, which may lead to error messages in the notebook:

ERROR: received unknown message
Message type: usage_request

See this discussion

Reproduce

  1. Install jupyterlab 4.0.4, jupyterlab-resource-usage 1.0.1 and e.g. xeus-cling 0.15.1 from conda-forge.
  2. Open a notebook and choose C++ as kernel
  3. Run some computations
  4. From time to time, the error will appear

(sorry, not great in terms of reproducibility :-) )

/cc @jtpio

@nthiery nthiery added the bug label Sep 26, 2023
@welcome
Copy link

welcome bot commented Sep 26, 2023

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@jtpio
Copy link
Member

jtpio commented Sep 28, 2023

Thanks @nthiery for opening the issue 👍

This might be related to the logic to detect whether the kernel usage is supported:

try:
import ipykernel
IPYKERNEL_VERSION = ipykernel.__version__
USAGE_IS_SUPPORTED = version.parse("6.9.0") <= version.parse(IPYKERNEL_VERSION)
except ImportError:
USAGE_IS_SUPPORTED = False
IPYKERNEL_VERSION = None

if not USAGE_IS_SUPPORTED:
self.write(
json.dumps(
{
"content": {
"reason": "not_supported",
"kernel_version": IPYKERNEL_VERSION,
}
}
)
)
return

These checks seem to be happening on the server extension regardless of which kernel is currently in use. Probably this means that if ipykernel is installed then the kernel usage will be enabled server side, even if another kernel is used in the notebook?

cc @echarles @krassowski @davidbrochart since this likely comes from the integration of the kernel usage panel in this repo: #164

@krassowski
Copy link
Collaborator

Yes, the code incorrectly assumes that the current kernel is always ipykernel. It also uses as of yet non-standard usage_request message. I would think that usage_request is a reasonable enhancement that we could propose as a JEP and codify in the Jupyter messaging specification, together with a way for kernel to announce that it supports it (or for client to probe if kernel does).

As a short-term solution (beside starting a pre-proposal for a JEP) I would imagine we could ensure that the request is sent at most once (i.e. avoid sending the message again if kernel did not reply).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants