Using and debugging Jupyter notebooks

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using and debugging Jupyter notebooks

WingIDE - User mailing list

Hi, I'm evaluating Wing in connection with Jupyter notebooks. I like the notebooks for their explorative and narrative style and the inclusion of media. I also like IDEs for better editing and debugging support. Debugging is totally mission in Jupyter. 

I have set up Jupyter with a notebook that imports an external Python file. Then I connected the Jupyter kernel to Wing for debugging and it works. I wrote down what I did here https://github.com/frankgerhardt/jupyter-notebook-debugging/blob/master/notebook.ipynb

However, what doesn't work is the sharing of variables between Jupyter and the Wing debugger. I'd like to be able to define a variable in the notebook and when I stop at a breakpoint in Wing I'd like to have access to that variable. And 2. in the opposite direction, I'd like to define variables in the imported Python file and have access to them in the Jupyter notebook. 

Any hints how to get this to work?

Frank


_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using and debugging Jupyter notebooks

WingIDE - User mailing list
On 6/4/16 10:14 PM, Frank Gerhardt via wingide-users wrote:

> I have set up Jupyter with a notebook that imports an external Python
> file. Then I connected the Jupyter kernel to Wing for debugging and it
> works. I wrote down what I did here
> https://github.com/frankgerhardt/jupyter-notebook-debugging/blob/master/notebook.ipynb
>
> However, what doesn't work is the sharing of variables between Jupyter
> and the Wing debugger. I'd like to be able to define a variable in the
> notebook and when I stop at a breakpoint in Wing I'd like to have access
> to that variable. And 2. in the opposite direction, I'd like to define
> variables in the imported Python file and have access to them in the
> Jupyter notebook.

Thanks for sharing this notebook; it is very helpful.

The hello variable is defined in the global namespace of your helper
module (in python, a file usually becomes a module when run) and can be
accessed from within a function defined in helper.py.  When I'm stopped
at a breakpoint in the foo() function, I can get the value of hello by
entering it in Wing's Debug Probe tool or by looking in globals in the
Stack Data tool.

To set a module global within a function such as set_greeting(), a
global statement is needed; for example:

def set_greeting(s):
     global hello
     hello = s

This is needed because python can't determine if you want to set a local
variable hello or update the global variable.  The global statement
specifies that you want to update the global hello variable.

Cheers,

John
_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Loading...