for i in range(10):
    j = i ** 2
    print("j =", j)

"""
Explanation: Debugging in JupyterLab
🇪🇺 🐍 EuroSciPy 2019 🐍 🇪🇺
<br>
Jeremy Tuloup - github.com/jtpio
<br>
<br>


1. Current tools for debugging Jupyter Notebooks

print statements
End of explanation
"""


for i in range(5):
    j = i ** 2
    breakpoint()  # Python 3.7+
    # import ipdb; ipdb.set_trace()
    print(j)

"""
Explanation: ipdb
End of explanation
"""


from IPython.display import YouTubeVideo

YouTubeVideo("Z-tPeEkVqjk", start=39, width=800, height=500)

"""
Explanation: PixieDebugger
End of explanation
"""


from IPython.display import Video

Video("./img/vscode-cell-debugging.mp4")

"""
Explanation: PyCharm, Visual Studio and other IDEs

Visual Studio Code Cell Debugging
From https://twitter.com/davorabbit/status/1149062343231455238
End of explanation
"""


x = 1

"""
Explanation: 2. Native debugging support for Jupyter Kernels
End of explanation
"""


for i in range(5):
    j = i + 1
    k = j ** 2
    print(j, k)

from ipywidgets import IntSlider

N = 5
slider = IntSlider(max=N)
slider

for i in range(N + 1):
    slider.value = i
    print(i)

"""
Explanation: New debug_request, debug_reply and debug_event messages
https://jupyter-client.readthedocs.io/en/latest/messaging.html#debug-request


- Adding a debugger to xeus-python
- Driven by Johan Mabille

https://github.com/jupyter/jupyter_client/issues/446
https://github.com/jupyter/jupyter_client/pull/447
https://github.com/jupyterlab/jupyterlab/pull/6544
https://github.com/jupyter/notebook/pull/4672
https://github.com/jupyter/jupyter_server/pull/56

Debug Protocol
- Standing on the shoulder of giants
- Debug Adapter Protocol: https://microsoft.github.io/debug-adapter-protocol/specification (used in VS Code)
- ptvsd (Python Tools for Visual Studio debug server)

Source: https://microsoft.github.io/debug-adapter-protocol/overview


3. Debugger extension for JupyterLab
- Active development
- https://github.com/jupyterlab/debugger
<br><br>
<div>
    <img style="margin: 20px" src="./img/quantstack-logo.svg" />
    <img style="margin: 20px" src="./img/bloomberg-logo.png" />
    <img style="margin: 20px" src="./img/two-sigma-logo.png" />
</div>

<br><br>


Prototype
Switching to xpython
End of explanation
"""


