Hello everyone. I’ve been using Jupyter for ages and I’m a big fan.
I’ve been following the Real-time collaboration without impersonation document. I’ve installed TLJH on Debian and I am able to collaborate using the collab accounts as described in the document.
But I would like to hide the collaboration UI elements for users when they are using their own non-collaborative accounts. I got the sense that this is what the pre_spawn_hook()
would do, but it doesn’t seem to have any effect in my testing.
I’m using the function directly from the document:
def pre_spawn_hook(spawner):
group_names = {group.name for group in spawner.user.groups}
if "collaborative" in group_names:
spawner.log.info(f"Enabling RTC for user {spawner.user.name}")
spawner.args.append("--LabApp.collaborative=True")
c.Spawner.pre_spawn_hook = pre_spawn_hook
While this didn’t seem to affect anything, I was able to implement the behavior I was looking for by impersonating the collab accounts (via sudo
) and installing jupyter-collaboration
in the “user install directory” with pip’s ‘–user’ flag, like so:
$ sudo -i -u jupyter-vox-collab
$ /opt/tljh/user/bin/python -m pip install --user jupyter-collaboration
I have a few questions:
Q1: I don’t notice any change whether I include the pre_spawn_hook()
or omit it entirely. Is it doing something that isn’t obvious to me or is it just not working? If it’s not working, how might I fix it?
Q2: Is my workaround (installing RTC into the collab account with ‘–user’) acceptable or could this cause problems later? Is there a better way to get the behavior I’m looking for?