diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b5dca8d..337bf1a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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:** diff --git a/otter/generate/templates/common/run_otter.py b/otter/generate/templates/common/run_otter.py index d7ffa0f4..9b0be562 100644 --- a/otter/generate/templates/common/run_otter.py +++ b/otter/generate/templates/common/run_otter.py @@ -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__": diff --git a/test/test_assign/files/example-autograder-correct/run_otter.py b/test/test_assign/files/example-autograder-correct/run_otter.py index 31a96ac8..9c519072 100644 --- a/test/test_assign/files/example-autograder-correct/run_otter.py +++ b/test/test_assign/files/example-autograder-correct/run_otter.py @@ -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__": diff --git a/test/test_assign/files/gs-autograder-correct/run_otter.py b/test/test_assign/files/gs-autograder-correct/run_otter.py index 31a96ac8..9c519072 100644 --- a/test/test_assign/files/gs-autograder-correct/run_otter.py +++ b/test/test_assign/files/gs-autograder-correct/run_otter.py @@ -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__": diff --git a/test/test_assign/files/rmd-autograder-correct/run_otter.py b/test/test_assign/files/rmd-autograder-correct/run_otter.py index 31a96ac8..9c519072 100644 --- a/test/test_assign/files/rmd-autograder-correct/run_otter.py +++ b/test/test_assign/files/rmd-autograder-correct/run_otter.py @@ -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__": diff --git a/test/test_generate/files/autograder-correct/run_otter.py b/test/test_generate/files/autograder-correct/run_otter.py index 31a96ac8..9c519072 100644 --- a/test/test_generate/files/autograder-correct/run_otter.py +++ b/test/test_generate/files/autograder-correct/run_otter.py @@ -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__": diff --git a/test/test_generate/files/autograder-custom-env/run_otter.py b/test/test_generate/files/autograder-custom-env/run_otter.py index 31a96ac8..9c519072 100644 --- a/test/test_generate/files/autograder-custom-env/run_otter.py +++ b/test/test_generate/files/autograder-custom-env/run_otter.py @@ -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__": diff --git a/test/test_generate/files/autograder-r-correct/run_otter.py b/test/test_generate/files/autograder-r-correct/run_otter.py index 31a96ac8..9c519072 100644 --- a/test/test_generate/files/autograder-r-correct/run_otter.py +++ b/test/test_generate/files/autograder-r-correct/run_otter.py @@ -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__": diff --git a/test/test_generate/files/autograder-r-requirements-correct/run_otter.py b/test/test_generate/files/autograder-r-requirements-correct/run_otter.py index 31a96ac8..9c519072 100644 --- a/test/test_generate/files/autograder-r-requirements-correct/run_otter.py +++ b/test/test_generate/files/autograder-r-requirements-correct/run_otter.py @@ -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__": diff --git a/test/test_generate/files/autograder-token-correct/run_otter.py b/test/test_generate/files/autograder-token-correct/run_otter.py index 31a96ac8..9c519072 100644 --- a/test/test_generate/files/autograder-token-correct/run_otter.py +++ b/test/test_generate/files/autograder-token-correct/run_otter.py @@ -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__": diff --git a/test/test_run/files/autograder/source/run_otter.py b/test/test_run/files/autograder/source/run_otter.py index d997e57e..f16281ca 100644 --- a/test/test_run/files/autograder/source/run_otter.py +++ b/test/test_run/files/autograder/source/run_otter.py @@ -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__": diff --git a/test/test_run/test_integration.py b/test/test_run/test_integration.py index cf32775d..b88f1ac8 100644 --- a/test/test_run/test_integration.py +++ b/test/test_run/test_integration.py @@ -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