Python AGPLv3 contest judge backend for the DMOJ site interface. See it in action at dmoj.ca!
A modern online judge and contest platform system, supporting IO-based, interactive, and signature-graded tasks, with runtime data generators and custom output validators. |
The judge implements secure grading on Linux and FreeBSD machines.
Linux | FreeBSD | |
---|---|---|
x64 | ✔ | ✔ |
x86 | ✔ | ¯\_(ツ)_/¯ |
x32 | ✔ | — |
ARM | ✔ | ❌ |
Versions up to and including v1.4.0 also supported grading on Windows machines.
The DMOJ judge does not need a root user to run on Linux machines: it will run just fine under a normal user.
Supported languages include:
- C++ 11/14/17 (GCC and Clang)
- C 99/11
- Java 8/9/10/11
- Python 2/3
- PyPy 2/3
- Pascal
- Perl
- Mono C#/F#/VB
The judge can also grade in the languages listed below. These languages are less tested and more likely to be buggy.
- Ada
- AWK
- COBOL
- D
- Dart
- Fortran
- Forth
- Go
- Groovy
- Haskell
- INTERCAL
- Kotlin
- Lua
- NASM
- Objective-C
- OCaml
- PHP
- Pike
- Prolog
- Racket
- Ruby
- Rust
- Scala
- Chicken Scheme
- sed
- Steel Bank Common Lisp
- Swift
- Tcl
- Turing
- V8 JavaScript
- Brain****
Installing the DMOJ judge creates two executables in your Python's script directory: dmoj
and dmoj-cli
.
dmoj
is used to connect a judge to a DMOJ site instance, while dmoj-cli
provides a command-line interface to a
local judge, useful for testing problems.
For more detailed steps, read the installation instructions.
Note that the only officially-supported Linux distribution is the latest Debian, with the default apt
versions of all runtimes. This is what we run on dmoj.ca, and it should "just work". While the judge will likely still work with other distributions and runtime versions, some runtimes might fail to initialize. In these cases, please file an issue.
We periodically publish builds on PyPI. This is the easiest way to get started, but may not contain all the latest features and improvements.
$ pip install dmoj
This is the version of the codebase we run live on dmoj.ca.
$ git clone https://github.com/DMOJ/judge.git
$ cd judge
$ git submodule update --init --recursive
$ pip install -e .
Several environment variables can be specified to control the compilation of the sandbox:
DMOJ_USE_SECCOMP
; set it tono
if you're building on a pre-Linux 3.5 kernel to disableseccomp
filtering in favour of pureptrace
(slower). This flag has no effect when building outside of Linux.DMOJ_TARGET_ARCH
; use it to override the default architecture specified for compiling the sandbox (via-march
). Usually this isnative
, but will not be specified on ARM unlessDMOJ_TARGET_ARCH
is set (a generic, slow build will be compiled instead).
$ dmoj --help
usage: dmoj [-h] [-p SERVER_PORT] -c CONFIG [-l LOG_FILE] [--no-watchdog]
[-a API_PORT] [-A API_HOST] [-s] [-k] [-T TRUSTED_CERTIFICATES]
[-e ONLY_EXECUTORS | -x EXCLUDE_EXECUTORS] [--no-ansi]
server_host [judge_name] [judge_key]
Spawns a judge for a submission server.
positional arguments:
server_host host to connect for the server
judge_name judge name (overrides configuration)
judge_key judge key (overrides configuration)
optional arguments:
-h, --help show this help message and exit
-p SERVER_PORT, --server-port SERVER_PORT
port to connect for the server
-c CONFIG, --config CONFIG
file to load judge configurations from
-l LOG_FILE, --log-file LOG_FILE
log file to use
--no-watchdog disable use of watchdog on problem directories
-a API_PORT, --api-port API_PORT
port to listen for the judge API (do not expose to
public, security is left as an exercise for the
reverse proxy)
-A API_HOST, --api-host API_HOST
IPv4 address to listen for judge API
-s, --secure connect to server via TLS
-k, --no-certificate-check
do not check TLS certificate
-T TRUSTED_CERTIFICATES, --trusted-certificates TRUSTED_CERTIFICATES
use trusted certificate file instead of system
-e ONLY_EXECUTORS, --only-executors ONLY_EXECUTORS
only listed executors will be loaded (comma-separated)
-x EXCLUDE_EXECUTORS, --exclude-executors EXCLUDE_EXECUTORS
prevent listed executors from loading (comma-
separated)
--no-ansi disable ANSI output
$ dmoj-cli --help
usage: dmoj-cli [-h] -c CONFIG
[-e ONLY_EXECUTORS | -x EXCLUDE_EXECUTORS]
[--no-ansi]
Spawns a judge for a submission server.
optional arguments:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
file to load judge configurations from
-e ONLY_EXECUTORS, --only-executors ONLY_EXECUTORS
only listed executors will be loaded (comma-separated)
-x EXCLUDE_EXECUTORS, --exclude-executors EXCLUDE_EXECUTORS
prevent listed executors from loading (comma-
separated)
--no-ansi disable ANSI output
For info on the problem file format and more, read the documentation.