Hello,
I try to deploy real-time collaboration in here Real-time collaboration without impersonation — JupyterHub documentation with z2jh. Here is part of my config:
hub:
extraConfig:
auth: |
from jupyterhub.auth import Authenticator
from tornado import gen
import re
class MyCustomAuthenticator(Authenticator):
@classmethod
def normalize_username(cls, username):
return re.sub(r"[@.]+","-",username.lower())
@gen.coroutine
def authenticate(self, handler, data):
return self.normalize_username(data['username'])
c.JupyterHub.authenticator_class = MyCustomAuthenticator
pre_spawn_hook: |
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")
print(f'#### group_names: {group_names} spawner.args: {spawner.args} #####')
# drop container capabilities for security reasons
spawner.container_security_context = {"capabilities": {"drop": ["ALL"]}}
c.KubeSpawner.pre_spawn_hook = pre_spawn_hook
auth_state_hook: |
def userdata_hook(spawner, auth_state):
spawner.userdata = auth_state
c.KubeSpawner.auth_state_hook = userdata_hook
init: |
project_config = {
"projects": {
"vox": {
"members": ["vex", "vax", "pike"]
},
"mighty": {
"members": ["fjord", "beau", "jester"]
}
}
}
c.JupyterHub.load_roles = []
c.JupyterHub.load_groups = {
# collaborative accounts get added to this group
# so it's easy to see which accounts are collaboration accounts
"collaborative": [],
}
for project_name, project in project_config["projects"].items():
# get the members of the project
members = project.get("members", [])
print(f"Adding project {project_name} with members {members}")
# add them to a group for the project
c.JupyterHub.load_groups[project_name] = members
allowed_users.update(members)
# define a new user for the collaboration
collab_user = f"{project_name}-collab"
# add the collab user to the 'collaborative' group
# so we can identify it as a collab account
c.JupyterHub.load_groups["collaborative"].append(collab_user)
# finally, grant members of the project collaboration group
# access to the collab user's server,
# and the admin UI so they can start/stop the server
c.JupyterHub.load_roles.append(
{
"name": f"collab-access-{project_name}",
"scopes": [
f"access:servers!user={collab_user}",
f"admin:servers!user={collab_user}",
"admin-ui",
f"list:users!user={collab_user}",
],
"groups": [project_name],
}
)
singleuser:
defaultUrl: /lab
image:
name: jupyter/datascience-notebook
tag: latest
pullPolicy: IfNotPresent
storage:
type: none
extraVolumes:
- name: jupyter-notebook-config
configMap:
name: jupyter-notebook-config
- name: exchange
persistentVolumeClaim:
claimName: exchange
extraVolumeMounts:
- name: jupyter-notebook-config
mountPath: '/usr/local/etc/jupyter/'
readOnly: true
- name: exchange
mountPath: '/home/jovyan'
(the rest of the config is usual config.)
But it doesn’t work for me (there’s no real-time collaboration). I was wondering how I can fix it? Is it related to jupyterhub version? How can I get my jupyterhub version & jupyterlab version?
Thanks in advance for your effort
best