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

Skip headers from jupyter kernelspec list. #423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ydl7
Copy link

@ydl7 ydl7 commented Dec 4, 2022

On certain configurations, juypter kernelspec list has a header with irrelevant information. This causes an error when parsing JSON output and can simply be ignored.

Example header:

0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

@nnicandro
Copy link
Collaborator

Do you still get those messages even when applying the fix in #418?

@lesteve
Copy link

lesteve commented Apr 20, 2023

I get this warning with Python 3.11. The fix in #418 (adding --log-level ERROR) does not help:

❯ jupyter kernelspec list --json --log-level ERROR
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
{
  "kernelspecs": {
    "python3": {
      "resource_dir": "/home/lesteve/.local/share/jupyter/kernels/python3",
      "spec": {
        "argv": [
          "python",
          "-m",
          "ipykernel_launcher",
          "-f",
          "{connection_file}"
        ],
        "env": {},
        "display_name": "Python 3 (ipykernel)",
        "language": "python",
        "interrupt_mode": "signal",
        "metadata": {
          "debugger": true
        }
      }
    }
  }
}

It seems to me that the best fix is to only consider stdout when executing jupyter commands as was proposed in #388 (which was closed in favour of #418), rather than adding more and more logic to discard unuseful info, which is what #418 did and and this PR proposes.

A compromise could be to add an additional argument to jupyter-command that would allow to ignore stderr. For a command like jupyter kernelspec list --json you know that you need to ignore stderr since otherwise it might not be valid json.

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

Successfully merging this pull request may close these issues.

3 participants