question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugging cells doesn't use the actual file with older versions of IPython

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Coderx7commented, Aug 7, 2019

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

1reaction
rchiodocommented, Aug 7, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging cells doesn't use the actual file with older versions ...
Start with this code here: #%% import torch import numpy as np import matplotlib.pyplot as plt %matplotlib inline # some test comments here!...
Read more >
Step-by-step debugging with IPython - Stack Overflow
A workaround is to place ipsh() a priori at the different locations where you want the Python interpreter to launch an IPython shell...
Read more >
IPython reference — IPython 3.2.1 documentation
Enter search terms or a module, class or function name. Warning. This documentation is for an old version of IPython. You can find...
Read more >
Run and debug Jupyter notebook code cells - JetBrains
Use the following smart shortcuts to quickly run the code cells: Ctrl+Enter : Runs the current cell. Shift+Enter : Runs the current cell...
Read more >
7.x Series — IPython 8.7.0 documentation
The debugger (and %debug magic) have been improved and can skip or hide frames originating from files that are not writable to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found