Skip to content

Commit

Permalink
emit a warning instead of an error for text written to stderr while v…
Browse files Browse the repository at this point in the history
…alidationg submission zips (#916)
  • Loading branch information
chrispyles authored Jan 27, 2025
1 parent 0acbe43 commit 939d0f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Wrap `ModuleNotFoundError` for `otter` in grading image to include debugging instructions per [#907](https://github.com/ucbds-infra/otter-grader/issues/907)
* Updated Otter Assign to disallow metadata tests for Colab notebooks per [#901](https://github.com/ucbds-infra/otter-grader/issues/901)
* Updated Otter Assign to leave solution cell tags in student notebooks per [#893](https://github.com/ucbds-infra/otter-grader/issues/893)
* Updated `Notebook.export` zip validation to emit a `RuntimeWarning` instead of a `RuntimeError` when anything is written to stderr per [#915](https://github.com/ucbds-infra/otter-grader/issues/915)

**v6.0.5:**

Expand Down
3 changes: 2 additions & 1 deletion otter/check/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import tempfile
import time
import warnings
import wrapt

from dataclasses import dataclass
Expand Down Expand Up @@ -111,7 +112,7 @@ def grade_zip_file(zip_path: str, nb_arcname: str, tests_dir: str) -> GradingRes
print(results.stdout.decode("utf-8"))

if results.stderr:
raise RuntimeError(results.stderr.decode("utf-8"))
warnings.warn(results.stderr.decode("utf-8"), RuntimeWarning)

with open(results_path, "rb") as f:
results = dill.load(f)
Expand Down
9 changes: 3 additions & 6 deletions otter/check/validate_export/__main__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""A Python module for validating that a submission zip file passes test cases"""

# suppress all warnings, because otherwise they get printed to stderr which triggers a RuntimeError
# in the calling code -- see #735
import warnings


# suppress all warnings, because otherwise they get printed to stderr which triggers a RuntimeError
# in the calling code -- see #735
warnings.simplefilter("ignore")


import argparse
import dill
import os
Expand All @@ -28,11 +29,7 @@ def get_parser():
return parser


warnings.warn("foo", RuntimeWarning)


def main():

args = get_parser().parse_args()

nb_dir = tempfile.mkdtemp()
Expand Down

0 comments on commit 939d0f3

Please sign in to comment.