automatic grading of jupyter notebooks
Project description
autograde is a tool for testing Jupyter notebooks. Its features include execution of notebooks (optionally isolated via docker/podman) with consecutive unit testing of the final notebook state. On top of that, an audit mode allows for refining results (e.g. grading plots by hand). Eventually, autograde can summarize these results in human and machine readable formats.
setup
Before installing autograde and in case you want to use it with a container backend, ensure docker or podman is available on your system. We recommend podman as it runs rootless.
Now, in order to install autograde, run pip install jupyter-autograde
.
Alternatively, you can install autograde from source by cloning this repository and runing pip install -e .
within it (or pip install -e .[develop]
if you’re a developer).
Eventually, build the respective container image: python -m autograde build
.
Note: in order to build a container image, autograde must not be installed via PyPI but from source code!
usage
testing
autograde comes with some example files located in the demo/
subdirectory that we will use for now to illustrate the workflow. Run:
python -m autograde test demo/test.py demo/notebook.ipynb --target /tmp --context demo/context
What happened? Let’s first have a look at the arguments of autograde:
demo/test.py
a script with test cases we want applydemo/notebook.ipynb
is the a notebook to be tested (here you may also specify a directory to be recursively searched for notebooks)The optional flag
--target
tells autograde where to store results,/tmp
in our case, and the current working directory by default.The optional flag
--context
specifies a directory that is mounted into the sandbox and may contain arbitrary files or subdirectories. This is useful when the notebook expects some external files to be present such as data sets.
The output is a compressed archive that is named something like results_[Lastname1,Lastname2,...]_XXXXXXXX.tar.xz
and which has the following contents:
artifacts/
: directory with all files that where created or modified by the tested notebook as well as rendered matplotlib plots.code.py
: code extracted from the notebook includingstdout
/stderr
as commentsnotebook.ipynb
: an identical copy of the tested notebooktest_restults.json
: test results
reports
The report
sub command creates human readable HTML reports from test results:
python -m autograde report path/to/result(s)
The respective report is added to the results archive inplace.
patching
Results from multiple test runs can be merged via the patch
sub command:
python -m autograde patch path/to/result(s) /path/to/patch/result(s)
summarize results
In a typical scenario, test cases are not just applied to one notebook but many at a time. Therefore, autograde comes with a summary feature, that aggregates results, shows you a score distribution and has some very basic fraud detection. To create a summary, simply run:
python -m autograde summary path/to/results
Two new files will appear in the result directory:
summary.csv
: aggregated resultssummary.html
: human readable summary report
help
To get an overview of all available commands and their usage, run
python -m autograde [sub command] --help
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jupyter_autograde-0.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85bf353279c443d73a2ba778ba4662b655bf95e9fbad8ae0ee0f5e08bfba74f6 |
|
MD5 | 1a4e145797dbf8695a26a7d74550e84d |
|
BLAKE2b-256 | 3ad3d8368fbe2f051118fe8e3df7406cae0890320afe7207a1ea5b7e1ae10f35 |