Skip to main content

Grade Jupyter notebooks with Python scripts

Project description

Jupygrader

Hatch project

PyPI - Version PyPI - Python Version


Table of Contents

Summary

Jupygrader is a Python package for automated grading of Jupyter notebooks. It provides a framework to:

  1. Execute and grade Jupyter notebooks containing student work and test cases
  2. Generate comprehensive reports in multiple formats (JSON, HTML, TXT)
  3. Extract student code from notebooks into separate Python files
  4. Verify notebook integrity by computing hashes of test cases and submissions

Key Features

  • Executes notebooks in a controlled, temporary environment
  • Preserves the original notebook while creating graded versions
  • Adds grader scripts to notebooks to evaluate test cases
  • Generates detailed grading results including:
    • Individual test case scores
    • Overall scores and summaries
    • Success/failure status of each test
  • Produces multiple output formats for instructors to review:
    • Graded notebook (.ipynb)
    • HTML report
    • JSON result data
    • Plaintext summary
    • Extracted Python code
  • Includes metadata like Python version, platform, and file hashes for verification

Jupygrader is designed for educational settings where instructors need to grade student work in Jupyter notebooks, providing automated feedback while maintaining records of submissions and grading results.

Installation

pip install jupygrader

Update Jupygrader

pip install --upgrade jupygrader

Usage

Basic usage

import jupygrader

notebook_file_path = 'path/to/notebook.ipynb'
jupygrader.grade_notebook(notebook_file_path)

Supplying a pathlib.Path() object is supported.

import jupygrader
from pathlib import Path

notebook_path = Path('path/to/notebook.ipynb')
jupygrader.grade_notebook(notebook_path)

If the output_dir_path is not specified, the output files will be stored to the same directory as the notebook file.

Specifying the output directory

import jupygrader

notebook_path = 'path/to/notebook.ipynb'
output_path = 'path/to/output'

jupygrader.grade_notebook(
    notebook_path=notebook_path,
    output_path=output_path
)

Development

Test project

hatch uses pytest as the test runner. All tests are defined in the tests/ directory.

hatch test

Print a code coverage table by using the --cover flag.

hatch test --cover

Generate a code coverage report

hatch run test:cov-html

# Output:
# Wrote HTML report to htmlcov\index.html

Build artifact

This creates a distribution package, which can be uploaded to PyPI.

  • Source distribution (sdist): dist\jupygrader-...tar.gz
  • Wheel distribution (wheel): dist\jupygrader-...-py3-none-any.whl
hatch build

Installing the built package locally

pip install dist\jupygrader-...-py3-none-any.whl

Publish to PyPI

hatch publish

# username: __token__
# password: [your-token-value]

Alternatively, you can create a ~/.pypirc file with the token credentials.

~/.pypirc

[pypi]
username = __token__
password = [your-token-value]

License

jupygrader is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupygrader-0.1.3.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupygrader-0.1.3-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file jupygrader-0.1.3.tar.gz.

File metadata

  • Download URL: jupygrader-0.1.3.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for jupygrader-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5368d37fb322ed332dd80a5e7a0b5bdb3279689b607b7a24019a43032aef1454
MD5 d59d5cb3bec593014fd325bf312e3e68
BLAKE2b-256 08ceba0a44eee2200d166db567b1122bf2839aa8e15e3169c602534cdc129ea0

See more details on using hashes here.

File details

Details for the file jupygrader-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: jupygrader-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for jupygrader-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 935dcbb2f55eeed3a7b708c67376e6e315293d33eae685f19a1a91afe020ba70
MD5 6f278beba5cd57798dfb4725fc4ce0c2
BLAKE2b-256 9108e854a1b3d8783539c6013007724fde259e7f26508d71054508bddadc2575

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page