GithubHelp home page GithubHelp logo

wanlo / autograde Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cssh-rwth/autograde

0.0 0.0 0.0 496 KB

Test jupyter notebooks in an isolated environment

License: MIT License

Dockerfile 0.35% Python 83.50% CSS 2.63% HTML 10.23% Jupyter Notebook 3.28%

autograde's Introduction

autograde

autograde test autograde on PyPI

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 poetry install within it. This requires poetry to be installed on your system!

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

Once installed, autograde can be invoked via the autograde command. If you are using a virtual environment (which poetry does implicitly) you may have to activate it first. Alternative methods:

  • `path/to/python -m autograde` runs autograde with a specific python binary, e.g. the one of your virtual environment.
  • `poetry run autograde` if you've installed autograde from source, you

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 apply
  • demo/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.zip 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 including stdout/stderr as comments
  • notebook.ipynb: an identical copy of the tested notebook
  • test_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 results
  • summary.html: human readable summary report

help

To get an overview of all available commands and their usage, run

python -m autograde [sub command] --help

autograde's People

Contributors

0b11001111 avatar wanlo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.