Hi,
as the title suggests: Formgrader paths do not seem to be compatible with square brackets in the path.
The console commands seem to work but the jupyter lab extension will just not display any assignments
I'm on macOS 15.4.1 24E263 arm64
Steps to reproduce:
mkdir "[test] nbgrader"
cd \[test\]\ nbgrader
nbgrader quickstart course_id
cd course_id
jupyter lab
Then, no assignments will be visible in the Formgrader extension. The command
nbgrader validate source/ps1/problem1.ipynb
still works.
Best, Tobi
Activity
perllaghu commentedon May 5, 2025
This is a known problem.... it stems from the fact that the various formgrader tools use regular expressions to separate the directory paths
{course_directory}/{nbgrader_step}/{student_id}/{assignment_id}/{notebook_id}.ipynb(see https://nbgrader.readthedocs.io/en/stable/user_guide/philosophy.html#how-to-structure-course-files)The characters
[{(]})\?+.all have special meaning in regular expressions, so mess up that calculation.lahwaacz commentedon May 5, 2025
@perllaghu Nevertheless, it should be fixed: every regex library has some escape function like
re.escape()in Python.perllaghu commentedon May 5, 2025
I had a similar problem in the service I run..... but for course codes - fortunately I could control that: I swapped all brackets & slashes for a high-order Unicode equivalent -
{->{, for example.This leaves the base nbgrader code-base unaffected, yet remains perfectly readable for the user.
[it did have an unfortunate side-effect: We support LTI connectivity & Grade Passback.... and
abc (12/3)!=abc(12∕3)- oops]..... however, yes: fixing the annoying regex problem would be good.
shreve commentedon May 8, 2025
Path escaping was added all the way back in 2016 (70d6c8f), but was set to False by default.
The code here is quite fishy to me, so I'm looking into why that might still be the case and see if we can't clean this up.
refactor: reduce reliance on regex in path handling
refactor: reduce reliance on regex in path handling
refactor: reduce reliance on regex in path handling