2.0: Auto-start notebook on login
mathis-marcotte opened this issue · comments
For 2.0, there will be a default notebook created in a user's namespace. That notebook will need to be auto-started when the user logins to their namespace.
This will need to be done in both centraldashboard for the login trigger, and jupyter-apis for the actual logic of starting a notebook.
The api call from jupyter api to start a notebook is a PATCH call to api/namespaces/{namespace}/notebooks/{name}
with the body {stopped: true}
. So, we just need to send that call to the jupyter api from whatever trigger we want(in this case, after the login) to start the notebook.
To know the name of which notebook to start, I see two ways we could find it:
- just copy paste how the name gets generated for the default notebook(namespace+"-notebook"). The reason I don't like this option is because it sets a dependency to how the name gets generated in a different repo(jupyter-apis and kubeflow) so if we change the default name for notebooks to something else, we would also need to remember to change it here as well.
- Find the notebook with the default label and start that one. The main downside of this solution over the other is that it is a bit more complexe since we have to go fetch the list of notebooks for the namespace and then filter through them. But it would be more safe to potential future changes, especially since labels are something internal so there are less chances of that changing compared to the notebook name
As a first draft, I added the api call in with the rest of the other api calls in the main-page.pug of centraldashboard that loads up the environment.
This call first gets the list of notebooks for the current namespace. Then, it loops through the notebooks to find the first one with the label notebook.statcan.gc.ca/default-notebook
set to true, as well as a status of "stopped". It then sends the request to start the notebook
Pr merged