Is there a way to be notified when a cell finishes execution in VSCode Jupyter Notebook?

Viewed 593

I'm using Jupyter Notebook on VSCode and would like to be notified when a cell finishes execution. I searched and was not able to find any extension for this task. Is there a way to get this working?

2 Answers

You could play a sound at the end of your Section after your code finishes. :-P

from playsound import playsound
playsound('/path/to/note.wav') # .wav file
playsound('/path/to/note.mp3') # .mp3 file

It's a way of creating an audio alert, if that suits your needs. You can borrow one of the audio alerts that come with whichever OS you are using.

If you are looking for a remote notification system, you could maybe email yourself or setup a twilio account.

Crucially, nobody wants to be notified when each and every cell is done executing. Rather, we want to be notified when a long-running cell finishes. So there should be a way to set a conditional such that if a cell finishes running under that threshold of time, there's no sound alert, but for the cells that take a long time to run, those cells play the alert sound upon completion.

Otherwise your notebook will sound like an orchestra of unnecessary "false positives" playing audible alerts for short-running cells.

Related