-
Notifications
You must be signed in to change notification settings - Fork 294
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
Jupyter plugin hides some custom kernelspecs when the executable defined in the argv cannot be found #13796
Comments
Thank you for filing this issue and sorry you are running into this. I've tested this at my end (with the exact same kernelspec json) and it works as expected. please can you test this with the latest version of Jupyter exetnsion
|
Ok, my bad. It appears that I changed "language" also and that was what affected things. My kernel spec that was not detected:
Thanks for the tip about "Jupyter: Show Output":
The message is a bit cryptic though.
It feels weird that the field affects how kernel is getting detected, don't you think? My use case is similar to "docker kernel" as in https://stackoverflow.com/a/63715102, i.e., it is python kernel but not locally installed. |
Thanks, I agree. Outside vscode users open terminals and have conda activated or the like, hence those executables are in the current path I understand that this doesn't work for you, i just wanted you to understand why we decided to exclude them (to avoide users frolm running into issues where the kernel might not start) I'll discuss this with the team |
Thanks for getting back to this! Another way that would work in my case: since I work with devcontainer I'd prefer to be able to explicitly specify the kernelspec(s) that I need instead of autodetect + filter option to exclude the ones that I don't need. |
Like @iakovn, myself (and actually multiple other physicists in my collaboration but I'm the one debugging it on our behalf) are hitting this. We'd like to be able to use VS Code's remote explorer to interact with Jupyter on remote environments but given some requirements for the software that we need in the environment (we need to be able to see and interact with the CernVM File System) we need to mutate the default kernelspec generated from something like (lcg-example) [23:01] login01.af.uchicago.edu:~ $ python -m ipykernel install --user --name="lcg-example" --display-name="Example LCG view + venv kernel"
Installed kernelspec lcg-example in /home/feickert/.local/share/jupyter/kernels/lcg-example
(lcg-example) [23:10] login01.af.uchicago.edu:~ $ cat ~/.local/share/jupyter/kernels/lcg-example/.bak.kernel.json
{
"argv": [
"/home/feickert/.venvs/lcg-example/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Example LCG view + venv kernel",
"language": "python",
"metadata": {
"debugger": true
}
}(lcg-example) [23:10] login01.af.uchicago.edu:~ $ to something that would allow for the environment manipulation suggested by the Jupyter team in jupyterhub/jupyterhub#847 (comment) (lcg-example) [23:11] login01.af.uchicago.edu:~ $ cat ~/.local/share/jupyter/kernels/lcg-example/kernel.json
{
"argv": [
"/home/feickert/.local/share/jupyter/kernels/lcg-example/startup.sh",
"-f",
"{connection_file}"
],
"display_name": "Example LCG view + venv kernel",
"language": "python",
"metadata": {
"debugger": true
}
}
(lcg-example) [23:11] login01.af.uchicago.edu:~ $ cat ~/.local/share/jupyter/kernels/lcg-example/startup.sh
#!/usr/bin/env bash
export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
# Allows for working with wrappers as well
source "${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh" --quiet || echo "~~~ERROR: setupATLAS failed!~~~"
lsetup 'views LCG_103 x86_64-centos7-gcc11-opt'
. ~/.venvs/lcg-example/bin/activate
exec python -m ipykernel_launcher $@
(lcg-example) [23:11] login01.af.uchicago.edu:~ $
@iakovn, can you elaborate on this? My experience with the valid kernelspec above is failure with VS Code failing to find the kernel at all. @DonJayamanne while I appreciate that the VS Code team might not want to make things visible by default, can it be made possible so that there is at least some dev option to still give a full path to a valid kernel? Environment:
Ouput after enabling
ATLAS Experiment internal reference link: https://atlas-talk.sdcc.bnl.gov/t/running-jupyter-notebooks-within-vscode/445 |
Using /bin/bash as the first element in argv and changing "language" to "python-custom" should solve the problem for you as far as I understand. |
Wow, indeed this works! Amazing and thank you!
I had previously run $ cat ~/.local/share/jupyter/kernels/lcg-example/kernel.json
{
"argv": [
"/bin/bash",
"/home/feickert/.local/share/jupyter/kernels/lcg-example/startup.sh",
"-f",
"{connection_file}"
],
"display_name": "Example LCG view + venv kernel",
"language": "python-custom",
"metadata": {
"debugger": true
}
} Thanks for your help @iakovn. @DonJayamanne Are there any official docs on using |
@iakovn Sorry one final question, from this do I correctly understand that |
That's my understanding, yes. Seems that the plugin has some undocumented heuristics for "python" aiming to automatically handle venvs. @DonJayamanne would be great if you explain the logic either here or in the docs. |
Thanks. Yes, from my limited understanding of kernelspecs from the
there's no constraint on "language". So we're just use But very much agreed that user docs from the VS Code team on this would be amazing! |
Hi everyone, I'm sorry about this issue, I will review the current workflow next iteration.
|
Thanks for these suggestions @DonJayamanne. I think both of these sound reasonable, but even just documentation on what the expected user behavior is would be great. |
Those are good fixes! If you can spend more time, then a new setting to explicitly specify kernels (instead of autodetect + hide not needed) would be great. In my devcontainer I need to exclude 5 choices out of 6... |
@DonJayamanne - are the original repro steps valid to verify this, and what is the expected behavior now? |
We continue to hide them but have a better message in the logs |
It seems to now attempt to start the kernel, and fail:
|
@amunger I'm not sure i understand the issue, |
oh sorry, we will still display these custom python kernel specs, and if it fails, its on the user, basically you have a bogus kernel spec, and we have no idea its bogus or not. So its correct to display these, thats whats expected. |
Environment data
Expected behaviour
All kernel spec visible in JupyterLab interface should appear in VSCode/Jupyter Kernels list as well. Eventually explicit error message (or warning) is shown if kernelspec is incomplete or broken in some way.
Extend documentation in https://github.com/microsoft/vscode-jupyter/wiki/General-overview-of-Kernel-Discovery-&-Execution-in-Jupyter-(&-extension)#1-global-kernelspecs and/or https://code.visualstudio.com/docs/datascience/jupyter-kernel-management#_jupyter-kernels to explicitly state what paths are searched and how broken or incomplete kernelspec are handled.
I was giving up trying jupyter plugin after not being able to use my kernel with it until I realized why it skips my kernel spec.
Actual behaviour
Some kernels are silently skipped during detection.
Steps to reproduce:
Put a kernel spec into ~/.local/share/jupyter/kernels/custom/kernel.json with a command on system path:
The kernel will be picked up by JupyterLab and will work as expected.
KernelPicker will not show the kernel in the list.
Resolution on my side was to change "mycommand" into "/full/path/mycommand" and it worked! Thanks for the great plugin!
EDIT: Per discussion below it's language set to be different from python (like "python-custom") that does the trick. With language set to "python", which is the default, the code makes some assumptions that are not valid for custom kernels.
The text was updated successfully, but these errors were encountered: