Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Stacked on #281. Grading a number that combines the log of a constant with a large power of 10, such as
log(0.1)*(10^8/ pi), ran past the 120 s Lambda timeout. The student got no grade, and the instance was held for the full timeout. This predates the refactor: the old grader stored empty responses for all 4 past submissions of this shape.The cause is SymPy's
simplify(), which callslogcombine. That rewrites-10^8*log(10)/piaslog(10**(-10**8))and builds a 100-million-digit integer. Two places hit it: the "simplified" display inevaluation.py, and the comparison indo_comparison. Parsing is not involved.Changes
app/time_budget.py(new): nested time limits enforced with SIGALRM. They're checked between bytecodes, which interrupts thissimplifypromptly.TimeBudgetExceededis aBaseException, so theexcept Exceptionaround SymPy calls can't swallow it. A limit does nothing off the main thread. The limits are 5 s per comparison and 60 s per request.app/context/symbolic.py: the symbolic attempts incheck_equalityrun under the comparison limit. If they run out of time,=falls back to comparing values to 50 digits.check_order,check_proportionalityand equality equivalence also run under the limit and grade as incorrect if they run out of time.app/context/numerical.py: addsnumerically_equal, andreplace_pimoves to module level. The fallback substitutes exactpi, because floatpiwould add noise at 50 digits.app/evaluation.py:TIME_LIMIT_EXCEEDEDfeedback (app/feedback/symbolic.py).log(0.1)*(10^8/ pi)vs(-1/(100*pi*k))*ln(r)+c900000+10^8* pi* log(100)vs1.47*10**8log(0.1)*(10^8/ pi)vs-10^8*log(10)/pi-10^8/( pi) log(r)vs(-1/(100*pi*k))*ln(r)+cNot covered: the
simplifycalls inapp/context/physical_quantity.py, and the variation code atsymbolic.py:615/620. They're bounded only by the 60 s request limit, not by their own fallbacks.Checklist
symbolic_evaluation_test.py;app/tests/time_budget_test.py.app/docs.md) if user-facing behaviour changed: only the new feedback message is user-facing.Testing
pytest app/tests: 1,223 passed, plus the 1 knowntest_radians_to_frequencyfailure (it also fails on Restructure app: split tests, previews and comparison helpers into modules #281).🤖 Generated with Claude Code