emacs-jupyter / jupyter

An interface to communicate with Jupyter kernels.
GNU General Public License v3.0
934 stars 92 forks source link

Expose refreshing kernelspecs #507

Closed sents closed 10 months ago

sents commented 11 months ago

jupyter-kernelspecs and associated functions have a refresh flag that triggers rereading of the available kernels.

When adding a new kernel, jupyter-server-launch-kernel seems to get the new kernel right away, but I mainly start my emacs-jupyter session with org mode sessions where I often get error messages that my selected kernel is not available. I can refresh the available kernelspecs by calling

(jupyter-kernelspecs (jupyter-tramp-server-from-file-name "/jpy:localhost#8888:test") t)

but that is confusing and hard to find for new users.

I think it would be good if there were an interactive function to refresh the kernelspecs or that emacs-jupyter refreshes the kernelspecs automatically if it can not find a selected kernel in org mode.

nnicandro commented 10 months ago

I've gone ahead and added a command, jupyter-refresh-kernelspecs, which can be called with point inside a src-block with a /jpy:host: session to refresh the kernelspecs of that host. It can also be called inside the jupyter-server-kernel-list-mode buffer to refresh the kernelspecs of that particular server. In general, it refreshes the kernelspecs of the host determined by the default-directory.

This was the easier route than refreshing the kernelspecs automatically, but refreshing the kernelspecs should, I think, be exposed to the user regardless of refreshing them automatically on every new session initiation, a feature I will leave to be implemented for the future. If anyone would like to tackle it, be my guest.