Skip to main content

Local Judge

PyPI Downloads Python version GitHub license Coding style Maintainability

Given source code, Makefile (or build commands), input files, and answer files then judge the program locally.

NOTE: this package is not an "online judge" (UVa, LeetCode, etc.) that allows you to solve some algorithmic problems but a tool that can judge (or correct) the students' compiler assignments (included but not limited to) by themselves and by the teaching assistants. You can still use this package to help simulate "online judge", which is not the goal of this work.

Workflow

Workflow

Screenshot

screenshot

Installation

  • For global usage:

    $ pip install local-judge
    
  • With virtualenv:

    $ virtualenv -p python3.6 venv
    $ source venv/bin/activate
    $ pip install local-judge
    

Features

  • Both
    • Automatically build the source code into executable
    • Automatically run the executable for each input and compare output with answer
    • Customization friendly
    • Able to leverage git diff tool to compare the result with the answer
  • Student (judge)
    • Without any dependencies but standard build-in python packages
  • TA (ta_judge)
    • Two dependencies packages: openpyxl, rarfile
    • Support different zip type (.zip, .rar)
    • When error is occurred, not interrupt or exit but just log it
    • Output to excel table
    • Multiprocessing

Environment (Recommended)

  • Ubuntu 18.04
  • python 3.6
  • git 2.17.1 (Our default diff tool for comparing between output and answer is git. Please make sure that you have installed it.)

Usage Examples

Documentation of Configuration

judge

  • judge.conf: be placed in the root of your program [example]
    • BuildCommand: how to build the executable
    • Executable: the name of the executable
    • RunCommand: how to run the executable with input and output
    • Inputs: input files (can use wildcard)
    • TempOutputDir: the temporary directory to place output files
    • DiffCommand: how to find differences between output and answer
    • DeleteTempOutput: whether to delete the temporary output after finding the differences (true or false)
    • AnswerDir: the directory where contains the answer files corresponding to the input files
    • AnswerExtension: the extension of the answer files
    • ExitOrLog: exit when any error occurred or just log the error
    • ScoreDict: the dictionary for the mapping of correctness and score
    • TotalScore: used if the number of tests is more than ScoreDict
    • Timeout: execution timeout for each test case

ta_judge

  • ta_judge.config: [example]
    • First part is judge.conf
    • StudentList: the execl file which contains student name and id
    • StudentsZipContainer: the directory where contains students' submit homeworks
    • StudentsPattern: used to match zip files
    • UpdateStudentPattern: used for update score of single student
    • StudentsExtractDir: the directory where contains extracted homeworks
    • ScoreOutput: the output excel file
    • ExtractAfresh: true: re-extract zipped file for each judge time; false: use pre-extracted files (under StudentsExtractDir) to judge

Contributing

Please make sure that you have installed pre-commit for linting the code with the black style.

Development

Environment

$ virtualenv -p python3.7 venv3.7
$ source venv3.7/bin/activate
$ python setup.py develop
$ pip install -e .
$ pip list
Package            Version Location
------------------ ------- ---------------------------------
black              21.12b0
click              8.0.3
et-xmlfile         1.1.0
importlib-metadata 4.10.0
local-judge        2.4.7   /home/ben/pro/selfpro/local-judge
mypy-extensions    0.4.3
openpyxl           3.0.9
pathspec           0.9.0
pip                21.0.1
platformdirs       2.4.1
rarfile            4.0
setuptools         54.1.1
tomli              1.2.3
typed-ast          1.5.1
typing-extensions  4.0.1
wheel              0.36.2
zipp               3.6.0

Run the test locally

$ python -m pytest tests/test_cli.py

License

MIT

Metadata

Release files for local-judge 2.7.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for local-judge 2.7.4
File Size Uploaded
local_judge-2.7.4.tar.gz 15.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for local-judge 2.7.4
File Interpreter ABI Platform
local_judge-2.7.4-py3-none-any.whl Python 3 none any Details

Total release size: 34.0 kB

Release files / local_judge-2.7.4.tar.gz

Download URL local_judge-2.7.4.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
52e39e020cf0532dff3014923a33c17b0083ff836097b7aefcea60a84da1e221
BLAKE2b-256 checksum
How to use checksums
4f7248f7e0cec54d461f5c66c33c48515049482cd58f6a74a6814d60afc892f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 18, 2025.

Transparency log

Release files / local_judge-2.7.4-py3-none-any.whl

Download URL local_judge-2.7.4-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05eaa0b839a518189cead604b7c33e5724e7d4b64eeeb111fae466fe31833caa
BLAKE2b-256 checksum
How to use checksums
3194df34f17b6c27c744802aa88bc6e6c80e901a5ab1751b1a0f4451198f0814
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 18, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

2.7.4 This release

2 release files

2.7.3

2 release files

2.7.2

2 release files

2.7.1

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.7

2 release files

2.4.6

2 release files

2.4.2

1 release file

2.4.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page