Given source code, Makefile (or build commands), input files, and answer files then judge the program locally.
Project description
Local Judge
Given source code, Makefile (or build commands), input files, and answer files then judge the program locally.
Workflow
+-------------------------------------------------------------------------------------+
| # TA (ta_judge.py): |
| +------------------------------[unzip]---------------------------+++++ |
| | # Student (judge.py): ||||| |
| | source code ---+ ||||| |
| | | [build] ||||| |
| | v ||||| |
| hidden inp. --> input ---> program ---> output ||||| |
| | [run] | ||||| |
| | v ||||| |
| hidden ans. --> answer -------------> [compare] ---> correctness, diff result ||||| |
| +-----------------------------------------|----------------------+++++ |
| ||||| [collect] |
| vvvvv |
| score table |
+-------------------------------------------------------------------------------------+
Screenshot
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.py
)- Without any dependencies but standard build-in python packages
- TA (
ta_judge.py
)- Support different zip type (
.zip
,.rar
) - When error is occurred, not interrupt or exit but just log it
- Output to excel table
- Multiprocessing
- Support different zip type (
Environment (Recommended)
- Ubuntu 18.04
- python 3.6
- git 2.17.1
Examples (with DEMO)
Usage (Student)
Configuration
judge.conf
: be placed in the root of your program- Content:
BuildCommand
: how to build the executableExecutable
: the name of the executableRunCommand
: how to run the executable with input and outputInputs
: input files (can use wildcard)TempOutputDir
: the temporary directory to place output filesDiffCommand
: how to find differences between output and answerDeleteTempOutput
: 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 filesAnswerExtension
: the extension of the answer filesExitOrLog
: exit when any error occurred or just log the errorScoreDict
: the dictionary for the mapping of correctness and scoreTotalScore
: used if the number of tests is more thanScoreDict
Timeout
: execution timeout for each test case
- Example config file:
[Config] BuildCommand = make clean && make Executable = scanner RunCommand = ./scanner < {input} > {output} Inputs = input/*.txt TempOutputDir = /tmp/output DiffCommand = git diff --no-index --color-words {answer} {output} DeleteTempOutput = true AnswerDir = answer AnswerExtension = .out ExitOrLog = exit ScoreDict = {"0":"0","1":"30","2":"60","3":"90","4":"100"} TotalScore = 100 Timeout = 5
- Content:
Commands
usage: judge.py [-h] [-c CONFIG] [-v VERBOSE]
optional arguments:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
the config file, default: `judge.conf`
-v VERBOSE, --verbose VERBOSE
the verbose level, default: `0`
`0`: suppress the diff results
`1`: show the diff results
-i INPUT, --input INPUT
judge only one input with showing diff result
path or test name both work
for example: `-i xxxx` or `-i ../input/xxxx.txt`
-o OUTPUT, --output OUTPUT
used to save outputs to a given directory without
judgement
Usage (TA)
Dependencies
judge.py
openpyxl
:pip3 install openpyxl
rarfile
:pip3 install rarfile
Configuration
ta_judge.config
- Content:
- First part is
judge.conf
StudentList
: the execl file which contains student name and idStudentsZipContainer
: the directory where contains students' submit homeworksStudentsPattern
: used to match zip filesUpdateStudentPattern
: used for update score of single studentStudentsExtractDir
: the directory where contains extracted homeworksScoreOutput
: the output excel fileExtractAfresh
: true: re-extract zipped file for each judge time; false: use pre-extracted files (underStudentsExtractDir
) to judge
- First part is
- Example config file:
[Config] BuildCommand = make clean && make Executable = scanner RunCommand = ./scanner < {input} > {output} Inputs = input/*.txt TempOutputDir = /tmp/output DiffCommand = git diff --no-index --color-words {answer} {output} DeleteTempOutput = true AnswerDir = answer AnswerExtension = .out ExitOrLog = exit ScoreDict = {"0":"0","1":"30","2":"60","3":"90","4":"100"} TotalScore = 100 Timeout = 5 [TaConfig] StudentList = student.xlsx StudentsZipContainer = ./zip StudentsPattern = ((\w*)_HW1)\.(.*) UpdateStudentPattern = Compiler_{student_id}_HW1 StudentsExtractDir = ./extract ScoreOutput = hw1.xlsx ExtractAfresh = true
- Content:
Commands
usage: ta_judge.py [-h] [-c CONFIG] [-t TA_CONFIG] [-s STUDENT]
optional arguments:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
the config file, default: `judge.conf`
-t TA_CONFIG, --ta-config TA_CONFIG
the config file, default: `ta_judge.conf`
-s STUDENT, --student STUDENT
judge only one student
-j JOBS, --jobs JOBS number of jobs for multiprocessing
-u UPDATE, --update UPDATE
update specific student's score by rejudgement
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
local-judge-2.4.1.tar.gz
(14.5 kB
view hashes)