otter.api Reference#
A programmatic API for using Otter-Grader
- otter.api.export_notebook(nb_path: str, dest: str | None = None, exporter_type: Literal['html'] | Literal['latex'] | None = None, **kwargs: Any)#
Exports a notebook file at
nb_pathto a PDF with optional filtering and pagebreaks. Accepts otherkwargspassed to the exporter class’sconvert_notebookclass method.- Parameters:
nb_path (
str) – path to notebookdest (
str | None) – path to write PDFexporter_type (
"html" | "latex" | None) – the type of exporter to use**kwargs – additional configurations passed to exporter
- Returns:
the path at which the PDF was written
- Return type:
str
- otter.api.grade_submission(submission_path: str, ag_path: str = 'autograder.zip', *, quiet: bool = False, debug: bool = False, extra_submission_files: list[str] | None = None) GradingResults#
Runs non-containerized grading on a single submission at
submission_pathusing the autograder configuration file atag_path.Creates a temporary grading directory using the
tempfilelibrary and grades the submission by replicating the autograder tree structure in that folder and running the autograder there. Does not run environment setup files (e.g.setup.sh) or install requirements, so any requirements should be available in the environment being used for grading.Print statements executed during grading can be suppressed with
quiet.- Parameters:
submission_path (
str) – path to submission fileag_path (
str) – path to autograder zip filequiet (
bool) – whether to suppress print statements during grading; defaultFalsedebug (
bool) – whether to run the submission in debug mode (without ignoring errors)extra_submission_files (
list[str] | None) – extra files to copy into the submission directory; this should really only be used internally by Otter, so use at your own risk
- Returns:
- the results object produced during the grading of the
submission.
- Return type:
otter.test_files.GradingResults