Getting error while submitting my outcome for Transfer_learning_with_MobileNet_v1 lab assignment

While submitting my solution for Cell #UNQ_C2, the autograder stops with this error:

Cell #UNQ_C2. Can't compile the student's code.
Error: SyntaxError("unmatched ')'",
('/tmp/student_solution_cells/cell_16.py', 41, 9, '        )'))

The traceback indicates that the grader fails when compiling the generated file:

File "/tmp/student_solution_cells/cell_16.py", line 41
    )
    ^
SyntaxError: unmatched ')'

This means the grader found a closing parenthesis ) on line 41 of the transformed cell code, but it does not have a corresponding opening parenthesis. The syntax error appears inside the auto-generated version of my cell, but I have been unable to identify the mismatched parenthesis within my submitted code.

The error prevents the model from compiling, and the grader does not execute any further tests.

I validated cell 16 but there is no syntax error. Unable to trace the line.

this is the final overall error statement

Cell #UNQ_C2. Can’t compile the student’s code. Error: SyntaxError(“unmatched ‘)’”, (‘/tmp/student_solution_cells/cell_16.py’, 41, 9, ’ )'))
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 41
)
^
SyntaxError: unmatched ‘)’

That problem has been seen before. Please see this thread for an explanation and fix.

Hello @paulinpaloalto - thanks for the solution, yet am getting the same error after making the correction as suggested in your post.
Cell #10. Can't compile the student's code. Error: SyntaxError("unmatched ')'", ('/tmp/student_solution_cells/cell_10.py', 18, 1, ')'))
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_10.py", line 18
)
^
SyntaxError: unmatched ')'

Are you sure you clicked Save after the change?

Yes, I saved the file after making the previous correction. Despite that getting this error. but this time, i see the issue is on cell_10 / earlier it was cell_16. So now am more confused of this bug.

Please check your DMs for a message from me about how to proceed. You can recognize DMs in your “feed” by the little envelope icon.

Also note that I don’t think you can deduce much from the cell numbers you see when you execute a notebook or the grader. You don’t know the order in which the grader calls your funcitons. The only reliable indicator is the exception trace, if you are lucky enough to get one from the grader. Does that look any different the second time?

I believe the cell numbers refer to the hidden notebook that the grader uses to test your code. The cell numbers do not refer to your notebook.

To close the loop on the public thread, we had a DM conversation to examine the code. It turns out that the close parentheses had not in fact been removed from their separate lines. And instead of one instance of this problem, there were actually 3 separate instances. :weary_cat:

All fixed now …

1 Like

Thanks @paul for the suggestions and solutions