microsoft / vscode-jupyter

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

Test Kernel Code Completions #14788

Closed DonJayamanne closed 11 months ago

DonJayamanne commented 11 months ago

Refs: #14672

Complexity: 5

Create Issue


Pre-Requisites

Julia Kernel Set * Option 1: Download Julia from here https://julialang.org/downloads/ * Open terminal and run `julia` * In the Julia REPL run ``` > using Pkg > Pkg.add("IJulia") ``` * Option 2: Create a dev container json with the following contents (file name `.devcontainer/devcontainer.json`) ```json { "image": "mcr.microsoft.com/devcontainers/universal:2", "features": { "ghcr.io/julialang/devcontainer-features/julia:1": {} } } ``` * Reload VS Code in that container (using the command `Reopen in container` * Uninstall Julia VS Code extension * Open terminal and run `julia` * In the Julia REPL run ``` > using Pkg > Pkg.add("IJulia") ```
R Kernel Setup * https://rocker-project.org/images/devcontainer/features.html * Or even simpler with `Anaconda` see https://datatofish.com/r-jupyter-notebook/

Steps

Python * Run the following code in a cell ```python import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(50, 4), columns=list('ABCD')) df.sample(frac=0.1, replace=True) ``` * Type in the text `df.` * [ ] Verify you get completions for each of the columns `A, B, C, D` * [ ] Click on the `>` icon against the word `helloWorld` in the completion item and verify you get documetnation for that * [ ] Verify the documetation for `df.A` is displayed and formatted Basically there should be some headers and code should be syntax highlighted * Type a lot of code and try to get a lot of completions (same code or different code, such as a complex/largers ipynb file) * Try to cause the kernel to crash by gettting a lot of completions and viewing the documentation * E.g. View completions, then expand to see the documentation, then use up/down arrow to view docs for each item. * VS Code will end up sending reqeusts for each selection on the completions list. * [ ] Verify you can still run code against the kernel and it is still responsive (i.e. its not slow due to completions)
Instructions Julia * Run a cell with the code `helloWorld = 1234` * In the next cell type in `hello` and then force completions for the remainder of the text using `ctrl+space` * [ ] Verify you get the completion for `helloWorld` * [ ] Click on the `>` icon against the word `helloWorld` in the completion item and verify you get documetnation for that * [ ] Type the text `ab` in another cell and then verify you get completion for `abs` * [ ] Verify the documetation for `abs` is displayed and formatted Basically there should be some headers and code should be syntax highlighted * [ ] Type the text `prin` in another cell and then verify you get completion for `print` * [ ] Verify the documetation for `print` is displayed and formatted Basically there should be some headers and code should be syntax highlighted
Instructions for R * Install the Bash shell using the code `python -m pip install bash` * Refresh list of Jupyter kernels in the kernel picker and select `Bash` * Run a cell with the code `var_global <-1` * In the next cell type in `var` and then force completions for the remainder of the text using `ctrl+space` * [ ] Verify you get the completion for `var_global` * [ ] Click on the `>` icon against the word `var_global` in the completion item and verify you get documetnation for that * [ ] Type the text `libr` in another cell and then verify you get completion for `library` (or prett ctrl+space) * [ ] Verify the documetation for `abs` is displayed and formatted Basically there should be some headers and code should be syntax highlighted
Instructions for Bash * Run a cell with the following code ``` display_id="id_${RANDOM}" ((ii=0)) while ((ii < 2)) ; do echo "
${ii}
" | displayHTML $display_id ((ii = ii+1)) sleep 1 done ``` * In the next cell run the text `displayHTML $` * [ ] Verify you get the completion for `$display_id`
amunger commented 11 months ago

dataframe column completions only show up for df[', not df. image

edit - I missed that I needed to disable Pylance, now I see them. (seems like a strange requirement to see more completion items)

amunger commented 11 months ago

just install Bash python package and thats it

@DonJayamanne - does this mean pip install bash? Is there supposed to be a new kernel to select after that (I don't see one)? the given bash code fails to run against the python kernel

rebornix commented 11 months ago

I seem to get auto complete working briefly but somehow after a few window reloads, I don't have them anymore, it only shows word based suggestions.

amunger commented 11 months ago

I seem to get auto complete working briefly but somehow after a few window reloads, I don't have them anymore, it only shows word based suggestions.

I was seeing something similar, but very inconsistently - and they usually come back within a minute or so or after executing something else.

DonJayamanne commented 11 months ago

was seeing something similar, but very inconsistently - and they usually c

kernel must be started to get completions

this mean pip install bash? Is there supp

Oops, please install bash kernel from here https://pypi.org/project/bash_kernel/

amunger commented 11 months ago

kernel must be started to get completions

yes, this is after running a cell. It sometimes still takes a minute before kernel completions show up.

rebornix commented 11 months ago

@DonJayamanne I do ensure that I rerun cells each time but I don't have luck.

DonJayamanne commented 11 months ago

got auto complete for the column names succesfully for data frame but I didn't see >.

What do you mean by ‘>’

DonJayamanne commented 11 months ago

@amunger @rebornix Please can you share the Jupyter logs for issues

rebornix commented 11 months ago

What do you mean by ‘>’

The documentation icon. However I know why it was not working. After a couple rebuild or reload of the dev container, the Jupyter extension was stable release but not prerelease ;( It works as expected.

A short summary of my testing after verifying the issues I reported against with prerelease:

joyceerhl commented 11 months ago

I can't find the option to select a bash kernel (in a codespace that has bash). I know @amunger mentioned a Jupyter Kernels section but I don't see one in the kernel picker. I am on the latest Jupyter prerelease

image image

DonJayamanne commented 11 months ago

e option to select a bash kernel (in a codespace that has bash)

You need to install the kernel, and might have to re-load VS Code to see the kernels show up again. I'll file an issue, we never display Jupyter Kernels entry if there are no kernels, and in your case installing them will require a re-load (we decided not to display an empty list if tehre are no kernels)

joyceerhl commented 11 months ago

I did install the kernel and reload the window

DonJayamanne commented 11 months ago

@joyceerhl Please can you share the logs, perhaps just file a new issue

joyceerhl commented 11 months ago

Filed, but I also cannot get to my Julia or R kernels in a standard Docker devcontainer (no codespace). I have the following features in my devcontainer.json

{
    "features": {
        "ghcr.io/devcontainers/features/desktop-lite:1": {},
        "ghcr.io/julialang/devcontainer-features/julia:1": {},
        "ghcr.io/rocker-org/devcontainer-features/r-apt:latest": {}
    }
}
DonJayamanne commented 11 months ago

Filed, but I also cannot get to my Julia or R kernels in a standard Docke

Weird, it worked for me, thats the one i used. Logs (verbose) will help