Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding nbgrader groups #5

Open
bpfrd opened this issue Jan 2, 2024 · 0 comments
Open

adding nbgrader groups #5

bpfrd opened this issue Jan 2, 2024 · 0 comments

Comments

@bpfrd
Copy link

bpfrd commented Jan 2, 2024

Hi,
in the bootstrap_pre_spawn function, you loop over courses and create formgrade-groups and roles as below:

groupsToCreate = {}

        base_port = 9000
        idx = 0
        for course, instructors in COURSES.items():
          # "outbound" must exist before starting a singleuser 
          if not os.path.exists(f'/mnt/exchange/{course}/outbound'):
            os.makedirs(f"/mnt/exchange/{course}/outbound")
          if not os.path.exists(f'/mnt/exchange/{course}/inbound'):
            os.makedirs(f"/mnt/exchange/{course}/inbound")
          if not os.path.exists(f'/mnt/exchange/{course}/feedback_public'):
            os.makedirs(f"/mnt/exchange/{course}/feedback_public")
          
          with open(f"/mnt/exchange/{course}/nbgrader_config.py", "w") as f:
            f.write("c = get_config()\n")
            f.write(f"c.CourseDirectory.root = '/mnt/exchange/{course}'\n")
            f.write(f"c.CourseDirectory.course_id = '{course}'\n")

          c.JupyterHub.services.append(
            {
              "name": course,
              "url": f"http://course-svc:{base_port + idx}",
              "command": ["jupyterhub-singleuser", f"--group=formgrade-{course}", f"--port={base_port + idx}", "--debug", "--ServerApp.ip=0.0.0.0"],
              "cwd": f"/mnt/exchange/{course}",
              "oauth_no_confirm": True,
              "environment" : {
                # Here nbgrader.auth.JupyterHubAuthPlugin needs a user, that always exists
                "JUPYTERHUB_USER": "admin"
              }
            }
          )

          groupsToCreate[f"nbgrader-{course}"] = []
          groupsToCreate[f"formgrade-{course}"] = instructors

          c.JupyterHub.load_roles.append({
            "name": f"formgrade-{course}",
            "groups": [f"formgrade-{course}"],
            "services": [course],
            "scopes": [
              f"access:services!service={course}", 
              f"read:services!service={course}", 
              f"list:services!service={course}", 
              "groups", 
              "users"
            ]
          })
          idx += 1

        c.JupyterHub.load_groups = groupsToCreate

what should I add if I want to create nbgrader- groups for students as well? in particular, should I create a service and add a role?
what rbac scopes should the role have?

best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant