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

Test Kernel Code Completions #14788

Closed
2 of 17 tasks
DonJayamanne opened this issue Nov 27, 2023 · 16 comments
Closed
2 of 17 tasks

Test Kernel Code Completions #14788

DonJayamanne opened this issue Nov 27, 2023 · 16 comments

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Nov 27, 2023

Refs: #14672

Complexity: 5

Create Issue


Pre-Requisites

  • Ability to run a Jupyter Notebook against a local Python kernel
  • Can run Python Kernels
  • Can run Bash Kernel (just install Bash python package and thats it, instructions below)
  • Can run Julia or R kernels (instructions below)
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)

    {
      "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

Steps

  • Enable the experiment KernelCompletions
  • Uninstall/disable Julia, Pylance, R extensions
  • Open into the experiment KernelCompletions
  • Run code against one of the above kernels (to have it started)
  • Test code completions (use CTRL+Space to force code completions)
  • Verify Python Kernel Completions
  • Verify Python Kernel Completions
  • Verify one of Julia or R Completions
Python
  • Run the following code in a cell
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 "<div>${ii}</div>" | 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
@DonJayamanne DonJayamanne changed the title Test Kernel Auto Completions WIP = Test Kernel Auto Completions Nov 27, 2023
@DonJayamanne DonJayamanne changed the title WIP = Test Kernel Auto Completions Test Kernel Auto Completions Nov 27, 2023
@DonJayamanne DonJayamanne added this to the November 2023 milestone Nov 27, 2023
@DonJayamanne DonJayamanne changed the title Test Kernel Auto Completions Test Kernel Code Completions Nov 27, 2023
@amunger
Copy link
Contributor

amunger commented Nov 28, 2023

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
Copy link
Contributor

amunger commented Nov 28, 2023

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
Copy link
Member

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
Copy link
Contributor

amunger commented Nov 28, 2023

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
Copy link
Contributor Author

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
Copy link
Contributor

amunger commented Nov 28, 2023

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
Copy link
Member

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

@DonJayamanne
Copy link
Contributor Author

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

What do you mean by ‘>’

@DonJayamanne
Copy link
Contributor Author

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

@rebornix
Copy link
Member

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
Copy link
Contributor

joyceerhl commented Nov 28, 2023

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
Copy link
Contributor Author

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
Copy link
Contributor

joyceerhl commented Nov 28, 2023

I did install the kernel and reload the window

@DonJayamanne
Copy link
Contributor Author

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

@joyceerhl
Copy link
Contributor

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
Copy link
Contributor Author

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

@joyceerhl joyceerhl removed their assignment Nov 29, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants