microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.25k stars 275 forks source link

Introduce a custom setting to add custom kernel path #15808

Open zhoonit opened 1 week ago

zhoonit commented 1 week ago

In the project I am working on, I have a custom kernel configurations to share with others. So I decided to put kernel.json in to the project as below.

- notebooks
   |- foo.ipynb
   |- bar.ipynb
- kernels
   |- pyspark
        |- kernel.json

with JUPYTER_PATH set, I could load/find custom kernel as expected.

$ JUPYTER_PATH=$(pwd) jupyter kernelspec list
Available kernels:
  python3    /my-project-root/.venv/share/jupyter/kernels/python3
  pyspark    /my-project-root/kernels/pyspark

This works just as intended as long as one could configure JUPYTER_PATH environmental variable when starting jupyter notebooks (not with vscode-jupyter).

With vscode-jupyter, it seems setting JUPYTER_PATH on launching jupyter notebook is not a viable option. It looked like "JUPYTER_PATH" is set to a temporary directory inside the extension.

image

I wonder if it is possible to add a setting to set location to search custom kernel directory.

something like below,

image

I've been digging into discussions and issues but couldn't find a way to do this. My apologies if this feature is already supported.

DonJayamanne commented 1 week ago

Please can you

If not, please can you share the logs using the command Jupyter: Show Output

zhoonit commented 4 days ago

Thank you for the detailed instruction.

I verified that the following instruction is able to apply JUPYTER_PATH to the vscode, and also learned that code launched with env variable set indeed regard the environment variables :)

While the instruction is more than enough to do the job, I wonder if there is a good way to overcome(?) those two minor issues.

  1. Sharing kernel spec without instructing users to do X and Y and then Z...
  2. If any documentation is inevitable, it should be also valid for various remote environment including code instance spawned with kubernetes, docker, ssh remote extension.

I thought of adding a setting to add kernel path or jupyter path and sharing the setting project-wide. (through .vscode/settings.json).

If the team is not happy with the suggestion, it is still okay for me since now I have a workaround. If the team thinks it's okay to be a feature with minor design tweaks but unlikely to implement seems low priority, I would be happy to give a shot to implement.