vscode-jupyter: Debugging cells doesn't use the actual file with older versions of IPython

Start with this code here:

#%%
import torch 
import numpy as np 
import matplotlib.pyplot as plt 
%matplotlib inline
# some test comments here! 
#%% 
from torchvision import datasets, transforms, models

transformations = transforms.ToTensor()
 
transformations = transforms.Compose([transforms.ToTensor(),
                                      # for normalizing note we used 0.5, that , 
                                      # is needed since mean and std requires a tuple
                                      transforms.Normalize(mean=(0.5,),std=(0.5,))]) 
# 
dataset_train = datasets.MNIST(root='MNIST', train=True, transform=transformations, download=True)
dataset_test = datasets.MNIST(root='MNIST', train=False, transform=transformations, download=True)

import torch.utils.data as data
dataloader_train = data.DataLoader(dataset_train, batch_size=32, shuffle=True, num_workers=2)
# we do the same thing for test 
dataloader_test = data.DataLoader(dataset_test, batch_size=32,shuffle=False,num_workers=2)
print(f'test dataloader size: {len(dataloader_test)}')

See the gif here provided by @Coderx7 debug_ipython_vscode3

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 18 (11 by maintainers)

Most upvoted comments

Updating the notebook to the latest version solved all the issues! there is no more a temporary file being generated, and the debugging happens inside the original file! Thanks a lot for your time and generous help!

Edit: For the record, my IPython version was 5.1.0 which was updated to the latest version as well. Basically these are the affected packages that were updated and thus made the issue get resolved:

Successfully installed Send2Trash-1.5.0 backcall-0.1.0 ipykernel-5.1.1 ipython-7.7.0 jedi-0.14.1 jsonschema-3.0.2 jupyter-client-5.3.1 jupyter-core-4.5.0 notebook-6.0.0 parso-0.5.1 pickleshare-0.7.5 prometheus-client-0.7.1 prompt-toolkit-2.0.9 pyrsistent-0.15.4 pywinpty-0.5.5 pyzmq-18.0.2 terminado-0.8.2 tornado-6.0.3

This code actually lives in iPython. So that version matters more:

import IPython; print(IPython.__version__)

And it looks like this used to be MD5.

Old version: https://github.com/ipython/ipython/blob/2961b531f0e7d137128e61ed6250074cc50a023a/IPython/core/compilerop.py#L58

Latest: https://github.com/ipython/ipython/blob/1879ed27bb0ec3be5fee499ac177ad14a9ef7cfd/IPython/core/compilerop.py#L59

Can you create another environment with the 6.0.0 version and see if it works there?