microsoft / vscode-jupyter

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

Test: Kernel communication upgrade #8024

Closed rchiodo closed 2 years ago

rchiodo commented 2 years ago

Refs: https://github.com/microsoft/vscode-jupyter/issues/7675

Complexity: 4

Create Issue


We've upgraded our internal library we use for communicating with kernels in the Jupyter extension to the latest jupyter lab services API

This version of the npm module looks to be a complete rewrite so we'd like to regression test all forms of communication with jupyter kernels.

Setup steps:

  1. Install some version of python
  2. Make sure you have pip installed
  3. Install Jupyter extension from marketplace (it is updated nightly, so it will have this month's changes in it)
  4. Install insiders Python extension

Test steps: (repeat multiple times)

  1. Create a python environment using either venv or conda. Alternatively you can use an existing environment.
  2. If using conda, try creating environments with different versions of python
  3. Open VS code in a new folder (if using venv, make sure the venv you created is located at the same root)
  4. Create a python file like so:
    # %%
    print('run cell')
  5. A bunch of code lenses should appear.
  6. Try using all of them
  7. You should be prompted to install ipykernel (if you haven't already)
  8. Try restarting the kernel
  9. Run a cell again, make sure it runs
  10. Run the following cell
    import sys
    !{sys.executable} -m pip install tqdm
  11. Add another cell like so (through the input box or the python file)
    # %%
    from tqdm import trange
    import time
    for i in trange(100):
    time.sleep(0.1)
  12. Make sure you can interrupt running of this cell, by clicking Interrupt at the top of the Interactive-1 editor.
  13. After interrupting make sure the kernel is still usable
  14. Using File | New File ... create a jupyter notebook
  15. Try the interrupt code in the notebook too
  16. Try restarting the kernel in the notebook too.
  17. Opening your settings.json and add this hidden setting:
    "jupyter.disableZMQSupport": true
  18. Rerun the steps above with that setting

Testing remote: (doesn't need to be done multiple times)

  1. On one of the venvs or conda environments you created before, install full jupyter
  2. In a command prompt, switch to your workspace folder
  3. Activate your venv/conda environment
  4. Run jupyter notebook. It should output something like so:

    [I 12:12:55.526 NotebookApp] Serving notebooks from local directory: D:\Source\Testing_3
    [I 12:12:55.526 NotebookApp] Jupyter Notebook 6.2.0 is running at:
    [I 12:12:55.526 NotebookApp] http://localhost:8888/?token=44a6967a96e31890585f51b1d64e50811917ba5d9d555ab3
    [I 12:12:55.526 NotebookApp]  or http://127.0.0.1:8888/?token=44a6967a96e31890585f51b1d64e50811917ba5d9d555ab3
    [I 12:12:55.527 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [C 12:12:55.675 NotebookApp]
    
    To access the notebook, open this file in a browser:
        file:///C:/Users/aku91/AppData/Roaming/jupyter/runtime/nbserver-10188-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=44a6967a96e31890585f51b1d64e50811917ba5d9d555ab3
     or http://127.0.0.1:8888/?token=44a6967a96e31890585f51b1d64e50811917ba5d9d555ab3
  5. Start VS code in the same workspace folder
  6. Run this command: image
  7. Pick Existing on the first quick pick
  8. Copy the URL from your terminal into the second quick pick.
  9. Restart VS code
  10. Run the steps above but use the default 'python 3' kernel (debugging doesn't work just yet)
  11. Make sure interrupt and restart tasks work
joaomoreno commented 2 years ago

Install Jupyter extension from marketplace (it has insiders only versions)

Not sure what this means. I just installed this one: https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter.

Also, after switching to the Python insiders, I eventually got this confusing message. I'm guessing this is a bug on Pylance?

image

joaomoreno commented 2 years ago

I also had a hard time with

from tqdm import trange <-- This might require you import a new module into the [kernel](https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/#How-to-use-Pip-from-the-Jupyter-Notebook). 

What solved it was

import sys
!{sys.executable} -m pip install tqdm

So I've updated the test plan item steps to tell the user to do just that, instead of linking to an obscure guide about Python/Pip/Jupyter internals.

joaomoreno commented 2 years ago

Run the steps above but use the default 'python 3' kernel

I've annotated this step, given that Debugging while attached to a remote server is not currently supported.

Overall, it's my first time trying out these ephemeral cells, this is pretty cool! 👏