Code works fine but grader throws error

i keep getting this error:

Cell #UNQ_C2. Can't compile the student's code. Error: SyntaxError("unmatched ')'", ('/tmp/student_solution_cells/cell_16.py', 39, 5, '    )'))
 Traceback (most recent call last):
  File "/home/www/app/grading/exceptions.py", line 112, in handle_solution_errors
    yield {}
  File "/home/www/app/grading/abstract.py", line 393, in _grade
    context = compiled_code.run(cell_index=cell.index)
  File "/home/www/app/grading/submission/compiled_code.py", line 195, in run
    return list(self._code_items.values())[cell_num - 1].run()
  File "/home/www/app/grading/submission/compiled_code.py", line 54, in run
    return import_module(self.import_statement, items)
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 839, in exec_module
  File "<frozen importlib._bootstrap_external>", line 976, in get_code
  File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/tmp/student_solution_cells/cell_16.py", line 39
    )
    ^
SyntaxError: unmatched ')'

it says there is an unmatched “)” in the code, but the code works perfectly fine

hi @rovshan99

in one of the syntax you wrote, it seems you have closed them 'syntax" with unmatched apostrophe or quotation marks, so look upon where this error has happened or check if you forgot to close a bracket ) ?

Regards
DP

The evidence is pretty clear that there is a syntax error in your notebook. If you are sure things run correctly when you run the notebook, then there are two theories:

  1. The error is somehow conditional and does not get triggered by the test cases in the notebook.
  2. You didn’t click “Save” before you submitted to the grader and the grader is seeing an older version of the notebook that has a bug in it that you have already fixed.

My guess is that 2) is the more likely scenario.

BTW you filed this under DLS C4 Convolutional Networks, but I do not recognize the pathnames shown in the exception trace above. Are you perhaps taking one of the TF courses?

Also, verify that you have not changed the notebook file name.

1 Like