I’ve freshly implemented a simple JupyterHub service
jupyterpost (pypi, repo) that converts this code
from jupyterpost import post from matplotlib import pyplot pyplot.plot([0, 1, 0]) post( "Hello from Jupyterhub :)", # Your message "@anton-akhmerov", # The channel, can be @username pyplot.gcf(), # Either matplotlib figure or bytes of the png image )
into this chat message:
jupyterpost only supports mattermost chat, but generalizing to more services (say slack) is within the project scope.
I found that adding a JupyterHub service requires changing a lot of moving parts:
- The service needs to be added to the hub
- Proper credentials need to be passed to the service downstream
- Users and in my case user servers need to get a permission to access it
- User servers need to know where to find this service
To simplify adding the service I implemented a convenience function for modifying the hub config in place, so that all of the above points are achieved by this code after all the other configuration is done:
from jupyterpost import configure_jupyterhub configure_jupyterhub( c, mattermost_token="your mattermost token", mattermost_url="https://your.mattermost.server/api/v4/", mattermost_team="your mattermost team name", jupyterpost_url="https://services.your.jupyterhub/services/jupyterpost", )
- Unfortunately I didn’t figure out how to compute the service URL (including protocol and domain) from the instance of hub config, that’s why I provide an additional config parameter. Any advice there?
- Is there any practical advice for testing hub services?