Skip to content

Commit

Permalink
wrap ModuleNotFoundError for otter in run_otter.py (#912)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles authored Jan 24, 2025
1 parent b005c67 commit 226ccc2
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Update Otter Assign to handle notebooks with an invalid kernelspec by assuming the language is Python per [#895](https://github.com/ucbds-infra/otter-grader/issues/895)
* Fixed assignment summary in Otter Assign so that manual questions are included per [#886](https://github.com/ucbds-infra/otter-grader/issues/886)
* Wrap `ModuleNotFoundError` for `otter` in grading image to include debugging instructions per [#907](https://github.com/ucbds-infra/otter-grader/issues/907)

**v6.0.5:**

Expand Down
11 changes: 10 additions & 1 deletion otter/generate/templates/common/run_otter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"""Runs Otter-Grader's autograding process"""

from otter.run.run_autograder import main as run_autograder
try:
from otter.run.run_autograder import main as run_autograder
except ModuleNotFoundError as e:
if "'otter'" in str(e):
raise RuntimeError(
"The 'otter' module could not be imported. This is usually caused by errors while building the "
"grading image, so check the image build logs and include them when requesting "
"support."
)
raise e


if __name__ == "__main__":
Expand Down
11 changes: 10 additions & 1 deletion test/test_assign/files/example-autograder-correct/run_otter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"""Runs Otter-Grader's autograding process"""

from otter.run.run_autograder import main as run_autograder
try:
from otter.run.run_autograder import main as run_autograder
except ModuleNotFoundError as e:
if "'otter'" in str(e):
raise RuntimeError(
"The 'otter' module could not be imported. This is usually caused by errors while building the "
"grading image, so check the image build logs and include them when requesting "
"support."
)
raise e


if __name__ == "__main__":
Expand Down
11 changes: 10 additions & 1 deletion test/test_assign/files/gs-autograder-correct/run_otter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"""Runs Otter-Grader's autograding process"""

from otter.run.run_autograder import main as run_autograder
try:
from otter.run.run_autograder import main as run_autograder
except ModuleNotFoundError as e:
if "'otter'" in str(e):
raise RuntimeError(
"The 'otter' module could not be imported. This is usually caused by errors while building the "
"grading image, so check the image build logs and include them when requesting "
"support."
)
raise e


if __name__ == "__main__":
Expand Down
11 changes: 10 additions & 1 deletion test/test_assign/files/rmd-autograder-correct/run_otter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"""Runs Otter-Grader's autograding process"""

from otter.run.run_autograder import main as run_autograder
try:
from otter.run.run_autograder import main as run_autograder
except ModuleNotFoundError as e:
if "'otter'" in str(e):
raise RuntimeError(
"The 'otter' module could not be imported. This is usually caused by errors while building the "
"grading image, so check the image build logs and include them when requesting "
"support."
)
raise e


if __name__ == "__main__":
Expand Down
11 changes: 10 additions & 1 deletion test/test_generate/files/autograder-correct/run_otter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"""Runs Otter-Grader's autograding process"""

from otter.run.run_autograder import main as run_autograder
try:
from otter.run.run_autograder import main as run_autograder
except ModuleNotFoundError as e:
if "'otter'" in str(e):
raise RuntimeError(
"The 'otter' module could not be imported. This is usually caused by errors while building the "
"grading image, so check the image build logs and include them when requesting "
"support."
)
raise e


if __name__ == "__main__":
Expand Down
11 changes: 10 additions & 1 deletion test/test_generate/files/autograder-custom-env/run_otter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"""Runs Otter-Grader's autograding process"""

from otter.run.run_autograder import main as run_autograder
try:
from otter.run.run_autograder import main as run_autograder
except ModuleNotFoundError as e:
if "'otter'" in str(e):
raise RuntimeError(
"The 'otter' module could not be imported. This is usually caused by errors while building the "
"grading image, so check the image build logs and include them when requesting "
"support."
)
raise e


if __name__ == "__main__":
Expand Down
11 changes: 10 additions & 1 deletion test/test_generate/files/autograder-r-correct/run_otter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"""Runs Otter-Grader's autograding process"""

from otter.run.run_autograder import main as run_autograder
try:
from otter.run.run_autograder import main as run_autograder
except ModuleNotFoundError as e:
if "'otter'" in str(e):
raise RuntimeError(
"The 'otter' module could not be imported. This is usually caused by errors while building the "
"grading image, so check the image build logs and include them when requesting "
"support."
)
raise e


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"""Runs Otter-Grader's autograding process"""

from otter.run.run_autograder import main as run_autograder
try:
from otter.run.run_autograder import main as run_autograder
except ModuleNotFoundError as e:
if "'otter'" in str(e):
raise RuntimeError(
"The 'otter' module could not be imported. This is usually caused by errors while building the "
"grading image, so check the image build logs and include them when requesting "
"support."
)
raise e


if __name__ == "__main__":
Expand Down
11 changes: 10 additions & 1 deletion test/test_generate/files/autograder-token-correct/run_otter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"""Runs Otter-Grader's autograding process"""

from otter.run.run_autograder import main as run_autograder
try:
from otter.run.run_autograder import main as run_autograder
except ModuleNotFoundError as e:
if "'otter'" in str(e):
raise RuntimeError(
"The 'otter' module could not be imported. This is usually caused by errors while building the "
"grading image, so check the image build logs and include them when requesting "
"support."
)
raise e


if __name__ == "__main__":
Expand Down
11 changes: 10 additions & 1 deletion test/test_run/files/autograder/source/run_otter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"""Runs Otter-Grader's autograding process"""

from otter.run.run_autograder import main as run_autograder
try:
from otter.run.run_autograder import main as run_autograder
except ModuleNotFoundError as e:
if "'otter'" in str(e):
raise RuntimeError(
"The 'otter' module could not be imported. This is usually caused by errors while building the "
"grading image, so check the image build logs and include them when requesting "
"support."
)
raise e


if __name__ == "__main__":
Expand Down
13 changes: 12 additions & 1 deletion test/test_run/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@

from otter.generate.token import APIClient
from otter.run import main as run_main
from otter.run.run_autograder import main as run_autograder


try:
from otter.run.run_autograder import main as run_autograder
except ModuleNotFoundError as e:
if "'otter'" in str(e):
raise RuntimeError(
"The 'otter' module could not be imported. This is usually caused by errors while building the "
"grading image, so check the image build logs and include them when requesting "
"support."
)
raise e
from otter.run.run_autograder.utils import OtterRuntimeError
from otter.test_files import GradingResults
from otter.utils import chdir, NBFORMAT_VERSION
Expand Down

0 comments on commit 226ccc2

Please sign in to comment.