jupyter / nbgrader

A system for assigning and grading notebooks
https://nbgrader.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.29k stars 317 forks source link

Add warning when course root is not accessible from notebook root #1012

Closed DavidNemeskey closed 5 years ago

DavidNemeskey commented 6 years ago

Operating system

Ubuntu 16.04

nbgrader --version

0.5.4

jupyterhub --version (if used with JupyterHub)

0.8.1

jupyter notebook --version

5.6.0

Expected behavior

I set the CourseDirectory.root to /opt/submissions. I expected that this would allow me to have multiple teachers work on the same course (adding students, creating assignments, etc). OK, I know that I should use a proper database for that, but it's a first step.

Actual behavior

With one of the teacher users I could create an assignment. However, when I clicked on it to actually edit it and create the assignment notebook, I got a 404. The URL the system looked at was /user/teacher/submissions/source/<assignment>/.

So it seems that somehow the /opt has become lost from the path, the submissions part was kept and put after the default /user/teacher/, which is the user's home.

If I change the root path to /home/teacher/nbgrader, everything works and the url is /user/teacher/tree/nbgrader/source/<assignment>/.

Note that the db was created in /opt/submissions just fine, I could add users... it's just the formgrader that has this problem.

Steps to reproduce the behavior

Just set CourseDirectory.root to outside the user's home directory.

DavidNemeskey commented 6 years ago

I know of #859 and #866, but I am on 0.5.4, and #866 was supposedly merged in 0.5.3.

sigurdurb commented 6 years ago

Is there any reason you don't have your course set up as a managed service and then only allow certain users to that service? Let me know if you need any help if you decide to do that 💃

DavidNemeskey commented 6 years ago

What do you mean by "not set up as a managed service"? (Preferably with links, please.) I am using the https://github.com/jupyterhub/jupyterhub-deploy-teaching repo, so I do have PAM authentication via JupyterHub. That is not the problem.

The problem is that if there are multiple teachers, they cannot cooperate on a single assignment, because each can only work in their own home. If nbgrader root was in a place that all teachers can access (e.g. /opt/submissions), they could. Students would still have their ngrader root inside their home directory.

Of course, I kind of solved the problem by having /home/<user>/nbgrader as the nbgrader root, only for teachers it is not a directory, but a symlink to /opt/submissions. So it's doable, but hacky.

sigurdurb commented 6 years ago

Managed service is basically having a notebook server running under the /services url. So step one is creating a new user on the system

For example: adduser --home /home/testcourse20183 --gecos "" --disabled-password testcourse20183 I set up mine based on this config But I also added some things that are not there: Here is an example

c.JupyterHub.services = [
{
        'name': 'testcourse20183',
        'url': 'http://127.0.0.1:9426',
        'command': [
            'jupyterhub-singleuser',
            '--group=testcourse_kenn',
            '--debug',
            '--MappingKernelManager.cull_idle_timeout=3600',
            '--MappingKernelManager.cull_interval=300',
        ],
        'user': 'testcourse20183',
        'cwd': '/home/testcourse20183'
    },
]

Then you need the groups

c.JupyterHub.load_groups = {
    'testcourse_kenn': [
        'testuser1',
        'testuser2',
        'testuser3',
    ],
}

Then only the users in testcourse_kenn are allowed to access the course on the path: /services/testcourse20183

jhamrick commented 6 years ago

Hmm, yeah, this has to do with the fact that nbgrader is running as part of the notebook server, which does not allow you to access notebooks outside of the directory where it is running. So it's not a limitation of the home directory itself, but a limitation that you cannot set the course directory to be outside the directory where the notebook server is running.

To support having multiple graders with JupyterHub, the recommended way is indeed as @sigurdurb suggested to use a JupyterHub service, see the documentation here: https://nbgrader.readthedocs.io/en/master/configuration/jupyterhub_config.html#example-use-case-one-class-multiple-graders

jhamrick commented 6 years ago

One thing we could potentially do is try to check if the root is being set outside the root of the notebook directory, and warn the user that this is not possible and point them to the relevant documentation for how to set up the JupyterHub service instead.