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

Misbehavior if root directory ends with / #1008

Closed
DavidNemeskey opened this issue Sep 11, 2018 · 1 comment · Fixed by #1123
Closed

Misbehavior if root directory ends with / #1008

DavidNemeskey opened this issue Sep 11, 2018 · 1 comment · Fixed by #1123
Labels
Milestone

Comments

@DavidNemeskey
Copy link

Operating system

Ubuntu 16.04

nbgrader --version

0.5.4

jupyterhub --version (if used with JupyterHub)

0.8.1

Expected behavior

To work as intended?

Actual behavior

I set the root directory to /home/teacher/nbgrader/ (note the / at the end).

This setup resulted in the following problems:

  • I created an assignment (with the grader user) hw1, but did not add anything to it. Switched to "Manage Students", came back, the assignment was missing.
  • I added a notebook to the assignment, tried to generate it, and got the following error:
Traceback (most recent call last):
  File "/opt/conda/lib/python3.6/site-packages/nbgrader/utils.py", line 371, in capture_log
    app.start()
  File "/opt/conda/lib/python3.6/site-packages/nbgrader/converters/assign.py", line 146, in start
    super(Assign, self).start()
  File "/opt/conda/lib/python3.6/site-packages/nbgrader/converters/base.py", line 72, in start
    self.convert_notebooks()
  File "/opt/conda/lib/python3.6/site-packages/nbgrader/converters/base.py", line 279, in convert_notebooks
    raise NbGraderException(msg)
nbgrader.converters.base.NbGraderException: Could not match '/home/teacher/nbgrader/source/./hw1' with regexp '\/home\/teacher\/nbgrader\/\/source\/(?P<student_id>.*)\/(?P<assignment_id>.*)'

Steps to reproduce the behavior

Described above.

I think the problem stems from the fact that convert_notebooks() calls format_path() with escape=True, which does not use os.path.join() to join the directories. So if the root directory (set via c.CourseDirectory.root) ends with the path separator, it ends up twice in the regex.

Note that my installation uses version 0.5.4, but the code seems to be the same in 0.6.

@jhamrick
Copy link
Member

jhamrick commented Oct 6, 2018

Confirmed. Probably the right thing here is to do some validation on root using os.path.abspath when root is set, thus ensuring that it doesn't have trailing slashes.

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

Successfully merging a pull request may close this issue.

2 participants