Notebook widget state is lost after kernel restart

Hi,

I have some widgets in my notebook (dropdowns/sliders etc). Now when the kernel is restarted, the widget state is lost and a message is displayed:

“Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells”

One way to solve this by clicking save widget state menu option. But I don’t want to do it manually. Is there a way I can save widget state using python code

What is your end goal? Yes, you can save widget state to a file or something with python code. However, that is not the same as saving widget state to the notebook, and won’t overcome that error.

I have some widgets getting generated on the notebook every time user execute some specific python functions. Now whenever we restart a kernel and user reopens the notebook, widget state they had earlier is lost and this message is displayed on the screen. User wants whatever widgets were there on their notebook before kernel restart should still be intact there. Kernel restart from backend should not impact user’s notebook state.

PS: Saving widget state from menu option is manual and we don’t want users to do that. We want to automate it in some way.

We are using jupyter notebook to build machine learning platform for data science folks of our organisation and so our main focus is to improve usability and experience of the consumers. Any suggestion/ideas on this one will be appreciated a lot. Thanks.

Did you find any solution for this?