Visual Studio Code & Jupyter

Thought I would call out some great success I had using Visual Studio Code and the Jupyter plugin.

The code completion and linting available in VS Code have been a life saver for getting up to speed with Python while wrangling cats vs dogs.

Caveats

6 Likes

This looks good. Thank you @wintermute. I have a question. Is there a way to run each line of the code where the cursor is present? I don’t see it mentioned anywhere in the documentation. It’s cumbersome to create the #%% cells to run a new block of code.

Thanks.

Is there a way to execute line by line? I don’t think so.
I organised my code code into 4 or 5 cells - this is what the structure of my final dogs vs cats looks like

#%%
 imports 
#%%
 collection of helper functions - this is where most of the logic is kept
#%%
 # orchestrate training
 execute training epochs
 save weights to disk
#%%  
 # orchestrate predictions
 load weights from disk
 execute predictions
 save predictions to disk
#%%
 # orchestrate csv writing
 load predictions from disk
 write kaggle submission csv

As I refined each ‘orchestration’ section of code, I factored it into functions and put it into the 2nd ‘helper function’ block.

Logic that I’m still refining is kept at the orchestration level so I only need to repeatedly execute a single cell as I work on and test it.

There is also Hydrogen for GitHub’s Atom editor.
I tried installing to play around with but had some problems getting the linter package to work - YMMV

One advantage over VS Code is it looks like this can connect to a remote Jupyter instance.

Remote Instance is a good feature to have. Eases the workflow.

I also figured out how to run the code line after line. (in Mac)

  1. Visit Code -> Preferences -> Keyboard Shortcuts.
  2. Type in “Jupyter”.
  3. Look for “Run Selection / Line”. Click “Edit” on the left.
  4. Enter your new key binding. Something like Shift + Enter similar to Jupyter. Save.

There are a couple of things which are annoying.

  1. Run selection/line and advance
  2. Auto-scroll in output
    Feature requests have been raised on github. If these are implemented, VSCode is quite handy.

I was having trouble using the ctrl+t command. I understand that we should generate our tags which I did using the plugin “jaydenlin.ctags-support” and also changed the workspace settings to include the path. But I am not able to get it work. Can you please help me?