-
Notifications
You must be signed in to change notification settings - Fork 19
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
Support incremental checking #9
Comments
Have you considered using tags in a cell to correspond to tests in the test suite? E.g. the
|
Interesting other option, @choldgraf! Thank you for bringing it up! I spent some time considering it, and it led me to write up a design doc (similar to what we have for r2d) https://github.com/grading/gradememaybe/blob/master/docs/design.md. It has some info on why I don't like relying on notebook metadata for critical functions. Your thoughts on that would be most welcome :) |
I also realized that one of the restrictions I have is unnecessarily strict:
The actual restriction should be:
This is easier to check & enforce, and does not require any external tooling for enforcing integrity. Students can be prevented from accidentally deleting check cells by marking them readonly, which is a feature built into most notebook frontends. |
I also wanted to provide more historical context here, to explain my thought process a bit more. Relying on notebook metadata is the approach taken by
It's not entirely clear to me the approach
This has a bunch of problems, primarily:
AST rewriting (which is what I hope to implement) is actually stolen from pytest. It's cons will become more apparent once we actually implement it :) I also <3 okpy & nbgrader, and they both have a lot of pros I have not listed here :) |
I thought @vipasu told me that he had addressed this issue. Is that true? If so, can we close it? |
Individual 'check' functions run tests against the state of the environment as it was when the user ran the check code. However, grade_notebook runs tests against the environment as it was when all the user code has been written. This has caused a lot of subtle, hard to debug errors.
For example, the following code works ok:
Assuming q1.py tests if a is 5 and q2 tests if a is 10.
However, if you add a 'grade_notebook' at the end, it'll always fail for q1, since a will be ten.
Re-assignment of variables used in tests will always fail. We could ask users to be careful about it, but that seems like an unnecessary restriction. Both nbgrader & okpy allow users to do incremental checking, so gradememaybe should also allow this.
okpy does this by using an object that collects grades. nbgrader does this by keeping tests directly in the notebook.
The approach I'd like to take here instead is to use AST rewriting to find all the 'check' calls and rewrite them to something else when grading!
The code above will be rewritten to:
check_results_abcdefg
is a list (or other object) that can collectTestResult
objects generated bycheck_abcdefg
. A randomly generated unique suffix is added to thecheck
functions to make it harder (but not impossible!) for students to cheat by simply redefining a 'check' function. Thecheck_results_abcdefg
object andcheck_abcdefg
function will be injected by the grading function as well. After all the code has been evaluated,check_results_abcdefg
can be evaluated to find the final grade.This imposes the following constraints on test notebook authors:
There should be a linter that validates these.
The text was updated successfully, but these errors were encountered: