Repository navigation
Report missing student functions as NOT_FOUND - #33
Draft
eliotwrobson wants to merge 1 commit into
Draft
eliotwrobson wants to merge 1 commit into
eliotwrobson wants to merge 1 commit into
Conversation
FunctionStatusCode.NOT_FOUND existed but the runner never sent it, so a missing function came back as an exception with KeyError and a traceback into the grader's own code. The runner now looks the function up separately from calling it, so only the lookup can produce NOT_FOUND. An error raised while the function runs stays an exception, even a KeyError or ImportError. In workspace mode, a missing module or attribute is NOT_FOUND, but a student module that exists and fails while loading is an exception, because hiding its real error wouldn't help anyone. query_function raises a NameError with the same message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Draft
1 task done
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
FunctionStatusCode.NOT_FOUNDexisted, andquery_functionhandled it, but the runner never sent it. The lookup sat inside the sametryas the call, so a missing function came back asexceptionwithKeyError: 'foo', andassert_fn_equalshowed a traceback into the grader's own_student_code_runner.py.Changes
NOT_FOUNDwith all the usual fields,exception_nameNameError,exception_messageFunction 'foo' wasn't found in the student code, and no traceback.query_function, and soassert_fn_equalandassert_fn_approx_equal, raises aNameErrorwith exactly that message. I removed theQuery for function 'foo' failed:prefix, which would have read awkwardly.NOT_FOUND. AKeyError,AttributeError,ImportErrororNameErrorraised while the function runs staysexceptionwith its normal details.Workspace mode:
NOT_FOUND.exception. This covers a bad import inside it, and any other error it raises while loading. Calling that "not found" would hide the error the student needs to see.Behaviour change for test authors: a test checking
response["status"] == "exception"for a missing function now needs"not_found". Tests checkingexception_name == "KeyError"need updating too.Unchanged:
foo = 5, staysexceptionwithTypeError: 'int' object is not callable. Its traceback still points at the grader's_student_code_runner.py, so that's a possible follow-up.sandbox.queryin workspace mode still treats a student module's ownImportErrororAttributeErroras not found, based on reading the code.I updated the expected messages in
test_stdout_featureandtest_quiz_2_1, which asserted the old wording for missing functions.quick_start.mdnow describesnot_found.Testing
test_function_not_foundandtest_workspace_function_not_foundscenarios. Both fail onmain.uv run pytest tests -p no:prairielearn-graderon Python 3.14: all 75 passed on two runs.uv run mypy --config-file pyproject.toml src tests, the command CI runs, is clean.ruff checkshows nothing new.docker/files, with this branch's wheel installed over PyPI 1.1.2. I confirmed its installed_student_code_runner.pyandfixture.pymatch the branch.ag, using PrairieLearn'sMarkovChains-Introtest_student.pyandleading_code.pywith notebooks based onMarkov-Chains-1.ipynb:...is inaccurateThe return value from your function power_iteration: NameError: Function 'power_iteration' wasn't found in the student code...: KeyError: 'power_iteration'#gradeline deletedThe message is repeated for the question's second test case. With the tag deleted, the student's function does exist but isn't in a graded cell, so the message says it wasn't found without mentioning the tag.
🤖 Generated with Claude Code