question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicating cells results in autograding failure because of duplicate IDs, and confusing error message

See original GitHub issue

This is similar to #981, as in that may solve the problem, but I’ll document core problem here and a workaround.

Students have submitted notebooks in which they have copied cells. This duplicates the metadata: of importance here is "nbgrader": {"grade_id": ...}. When this happens, the following error message is given:

[AutogradeApp | WARNING] Cell with id 'Task_3_1_test' exists multiple times!
...
[AutogradeApp | WARNING] Removing failed assignment: /m/jhnas/jupyter/course/mlpython2019/files/autograded/staafv1/R1_Introduction
[AutogradeApp | ERROR] One or more notebooks in the assignment use an old version of the nbgrader metadata format. Please **back up your class files directory** and then update the metadata using: nbgrader update .

The first warning is the key to the problem. However, the error message shows that nbgrader metadata should be updated, which not the real problem here (though I haven’t tested it if actually works). At least, the error message could be improved or the failure could be noticed earlier.

It isn’t a perfect solution, but it would be nice if nbgrader could also continue on in this case. Clearly the student has done something weird (and notebook/jupyterlab could solve it by not duplicating metadata). But could nbgrader also survive this and make some choice one way or the other itself, considering that duplicating metadata is probably a type of problem that will appear again? That way the common case won’t cause a failure stopping all autograding… and we leave it to instructors to tell of the problem later.

Who knows what the right nbgrader-only solution would be - simple would be to pick the last cell with the metadata. But many corner cases could break this.

Workaround for anyone else who gets this problem: My tests showed that you have to delete the whole nbgrader metadata dict from the notebook cell - changing the grade_id is not enough because it can’t find that grade_id in the database, nor is removing just the grade_id cell.

Operating system

Linux

nbgrader --version

Modified version, based on upstream d56f75b (close to current master).

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

7reactions
trevorcampbellcommented, Jan 18, 2020

Just adding a +1 to this – I ran in to this exact issue in my course just now!

1reaction
elesiutacommented, Jul 12, 2019

I experienced this issue as well in the class I recently TA’d (nbgrader 0.5.4 on jupyterhub 0.9.4). My solution was a script that merges cells when it detects duplicate grade_ids by concatenating the cell’s source to the first then removing the duplicate.

I uploaded the script as part of a small collection I wrote for that course in case it’s of use to anyone https://github.com/elesiuta/jupyter-nbgrader-helper (run with --fix AssignName NbName.ipynb). As an aside, if there’s any feature in there you think might be useful to implement properly into nbgrader I’d be happy to open a pull request and work on it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data Refresh Fails, Error message claims duplicate ID value ...
I went to my actual SQL DB and ran a query on the table for the exact ID provided by the error message....
Read more >
A Step-by-Step Guide on How to Remove Duplicates in Excel
Select the range of cells containing duplicate values that should be removed. · By selecting Data > Remove Duplicates and then checking or ......
Read more >
Error 'Duplicate value found' when updating records using ...
When running an update via Data Loader, you may encounter the error 'duplicate value found.' This is due to a duplicate within a...
Read more >
Compare two columns and remove duplicates in Excel - Ablebits
Now that you have lots of workbooks with a pool of data, or maybe just one huge table, you may want to compare...
Read more >
Duplicate Labels — pandas 1.5.2 documentation
And real-world data has duplicates, even in fields that are supposed to be ... for large datasets. pandas does cache this result, so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found