Skip to main content

Grade Jupyter notebooks with Python scripts

Project description

Jupygrader Logo

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.5.tar.gz (14.6 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.5-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for jupygrader-0.1.5.tar.gz
Algorithm Hash digest
SHA256 da03480017de398b303b62dc714f01f3d7316320e6522765372d2ce73b94ccbf
MD5 bded14e9ae07486b0849455899d07ae2
BLAKE2b-256 ee6c5263c5bd2591713ae5d4c96e4dbbfedc8267ff5f41d005c79b59d60e791c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for jupygrader-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5068cb676b3a04a74df7ade57c5f762204706752da36b099ad982cb756dabdae
MD5 7a16c56d8484fe071e14ccb242dba9b8
BLAKE2b-256 b3061793be3cbdc5261dc1a67c8af77b23b6fd217ade70831f09529900025baf

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