<h1 align="center">
<img src="https://avatars2.githubusercontent.com/u/6934864?v=3&s=1000" width="120px">
<br>
DMOJ Judge
</h1>
<p align="center">
<a href="https://github.com/DMOJ/judge-server/actions?query=workflow%3Abuild">
<img alt="Linux Build Status" src="https://img.shields.io/github/actions/workflow/status/DMOJ/judge-server/build.yml?branch=master&logo=linux"/>
</a>
<a href="https://ci.dmoj.ca/view/DMOJ/job/dmoj-judge-freebsd-py3/">
<img alt="FreeBSD Build Status" src="https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fci.dmoj.ca%2Fview%2FDMOJ%2Fjob%2Fdmoj-judge-freebsd-py3%2F&logo=freebsd"/>
</a>
<a href="https://codecov.io/gh/DMOJ/judge-server">
<img alt="Coverage" src="https://img.shields.io/codecov/c/github/DMOJ/judge-server.svg"/>
</a>
<a href="LICENSE.md">
<img alt="License" src="https://img.shields.io/github/license/DMOJ/judge-server"/>
</a>
<a href="https://dmoj.ca/about/discord/">
<img src="https://img.shields.io/discord/677340492651954177?color=%237289DA&label=Discord"/>
</a>
</p>
Contest judge backend for the [DMOJ site](https://github.com/DMOJ/online-judge) interface, supporting <b>IO-based</b>, <b>interactive</b>, and <b>signature-graded</b> tasks, with <b>runtime data generators</b> and <b>custom output validators</b>.
See it in action at [dmoj.ca](https://dmoj.ca/)!
## Supported platforms and runtimes
The judge implements secure grading on Linux and FreeBSD machines.
| | Linux | FreeBSD |
| --: | :---: | :-----: |
| x64 | [✔](https://github.com/DMOJ/judge-server/actions/workflows/build.yml) | [✔](https://ci.dmoj.ca/job/dmoj-judge-freebsd/) |
| x86 | ✔ | ¯\\\_(ツ)\_/¯ |
| x32 | ✔ | — |
| ARM | [✔](https://github.com/DMOJ/judge-server/actions/workflows/build.yml) | ❌ |
Versions up to and including [v1.4.0](https://github.com/DMOJ/judge-server/releases/tag/v1.4.0) also supported grading on Windows machines.
Versions up to and including [v3.0.2](https://github.com/DMOJ/judge-server/releases/tag/v3.0.2) also supported grading
with pure ptrace without seccomp, which is useful on Linux kernel versions before 4.8.
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/20 (GCC and Clang)
* C 99/11
* Java 8-19
* Python 2/3
* PyPy 2/3
* Pascal
* Mono C#/F#/VB
The judge can also grade in the languages listed below:
* Ada
* AWK
* COBOL
* D
* Dart
* Fortran
* Forth
* Go
* Groovy
* Haskell
* INTERCAL
* Kotlin
* Lean 4
* LLVM IR
* Lua
* NASM
* Objective-C
* OCaml
* Perl
* PHP
* Pike
* Prolog
* Racket
* Ruby
* Rust
* Scala
* Chicken Scheme
* sed
* Steel Bank Common Lisp
* Swift
* Tcl
* Turing
* V8 JavaScript
* Brain\*\*\*\*
* Zig
## Installation
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](https://docs.dmoj.ca/#/judge/setting_up_a_judge).
Note that **the only Linux distribution with first-class support is the latest Debian**, with the default `apt` versions of all runtimes. This is [what we run on dmoj.ca](https://dmoj.ca/runtimes/matrix/), 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](https://github.com/DMOJ/judge-server/issues).
### Stable build
[](https://pypi.python.org/pypi/dmoj)
[](https://pypi.python.org/pypi/dmoj)
We periodically publish builds [on PyPI](https://pypi.python.org/pypi/dmoj). This is the easiest way to get started,
but may not contain all the latest features and improvements.
```
$ pip install dmoj
```
### Bleeding-edge build
This is the version of the codebase we run live on [dmoj.ca](https://dmoj.ca/).
```
$ git clone --recursive https://github.com/DMOJ/judge-server.git
$ cd judge-server
$ pip install -e .
```
Several environment variables can be specified to control the compilation of the sandbox:
* `DMOJ_TARGET_ARCH`; use it to override the default architecture specified for compiling the sandbox (via `-march`).
Usually this is `native`, but will not be specified on ARM unless `DMOJ_TARGET_ARCH` is set (a generic, slow build will be compiled instead).
### With Docker
We maintain Docker images with all runtimes we support in the [runtimes-docker](https://github.com/DMOJ/runtimes-docker) project.
Runtimes are split into three tiers of decreasing support. Tier 1 includes
Python 2/3, C/C++ (GCC only), Java 8, and Pascal. Tier 3 contains all the
runtimes we run on [dmoj.ca](https://dmoj.ca/). Tier 2 contains some in-between
mix; read the `Dockerfile` for each tier for details. These images are rebuilt
and tested every week to contain the latest runtime versions.
The script below spawns a tier 1 judge image. It expects the relevant
environment variables to be set, the network device to be `enp1s0`, problems
to be placed under `/mnt/problems`, and judge-specific configuration to be in
`/mnt/problems/judge.yml`. Note that runtime configuration is already done for you,
and will be merged automatically into the `judge.yml` provided.
```
$ git clone --recursive https://github.com/DMOJ/judge-server.git
$ cd judge-server/.docker
$ make judge-tier1
$ exec docker run \
--name judge \
-p "$(ip addr show dev enp1s0 | perl -ne 'm@inet (.*)/.*@ and print$1 and exit')":9998:9998 \
-v /mnt/problems:/problems \
--cap-add=SYS_PTRACE \
-d \
--restart=always \
dmoj/judge-tier1:latest \
run -p15001 -s -c /problems/judge.yml \
"$BRIDGE_ADDRESS" "$JUDGE_NAME" "$JUDGE_KEY"
```
## Usage
### Running a judge server
```
$ 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
--skip-self-test skip executor self-tests
```
### Running a CLI judge
```
$ 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
--skip-self-test skip executor self-tests
```
## Documentation
For info on the problem file format and more, [read the documentation](https://docs.dmoj.ca).
Raw data
{
"_id": null,
"home_page": "https://github.com/DMOJ/judge-server",
"name": "dmoj",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "online-judge",
"author": "DMOJ Team",
"author_email": "contact@dmoj.ca",
"download_url": "https://files.pythonhosted.org/packages/5d/67/24b2e27db2a3bcf5942373a85d0eee37bbffdc7abb90edd5192b7b269c01/dmoj-4.0.1.tar.gz",
"platform": null,
"description": "<h1 align=\"center\">\n <img src=\"https://avatars2.githubusercontent.com/u/6934864?v=3&s=1000\" width=\"120px\">\n <br>\n DMOJ Judge\n</h1>\n<p align=\"center\">\n <a href=\"https://github.com/DMOJ/judge-server/actions?query=workflow%3Abuild\">\n <img alt=\"Linux Build Status\" src=\"https://img.shields.io/github/actions/workflow/status/DMOJ/judge-server/build.yml?branch=master&logo=linux\"/>\n </a>\n <a href=\"https://ci.dmoj.ca/view/DMOJ/job/dmoj-judge-freebsd-py3/\">\n <img alt=\"FreeBSD Build Status\" src=\"https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fci.dmoj.ca%2Fview%2FDMOJ%2Fjob%2Fdmoj-judge-freebsd-py3%2F&logo=freebsd\"/>\n </a>\n <a href=\"https://codecov.io/gh/DMOJ/judge-server\">\n <img alt=\"Coverage\" src=\"https://img.shields.io/codecov/c/github/DMOJ/judge-server.svg\"/>\n </a>\n <a href=\"LICENSE.md\">\n <img alt=\"License\" src=\"https://img.shields.io/github/license/DMOJ/judge-server\"/>\n </a>\n <a href=\"https://dmoj.ca/about/discord/\">\n <img src=\"https://img.shields.io/discord/677340492651954177?color=%237289DA&label=Discord\"/>\n </a>\n</p>\n\nContest judge backend for the [DMOJ site](https://github.com/DMOJ/online-judge) interface, supporting <b>IO-based</b>, <b>interactive</b>, and <b>signature-graded</b> tasks, with <b>runtime data generators</b> and <b>custom output validators</b>.\n\nSee it in action at [dmoj.ca](https://dmoj.ca/)!\n\n## Supported platforms and runtimes\n\nThe judge implements secure grading on Linux and FreeBSD machines.\n\n| | Linux | FreeBSD |\n| --: | :---: | :-----: |\n| x64 | [\u2714](https://github.com/DMOJ/judge-server/actions/workflows/build.yml) | [\u2714](https://ci.dmoj.ca/job/dmoj-judge-freebsd/) |\n| x86 | \u2714 | \u00af\\\\\\_(\u30c4)\\_/\u00af |\n| x32 | \u2714 | — |\n| ARM | [\u2714](https://github.com/DMOJ/judge-server/actions/workflows/build.yml) | \u274c |\n\nVersions up to and including [v1.4.0](https://github.com/DMOJ/judge-server/releases/tag/v1.4.0) also supported grading on Windows machines.\n\nVersions up to and including [v3.0.2](https://github.com/DMOJ/judge-server/releases/tag/v3.0.2) also supported grading\nwith pure ptrace without seccomp, which is useful on Linux kernel versions before 4.8.\n\nThe DMOJ judge does **not** need a root user to run on Linux machines: it will run just fine under a normal user.\n\nSupported languages include:\n\n* C++ 11/14/17/20 (GCC and Clang)\n* C 99/11\n* Java 8-19\n* Python 2/3\n* PyPy 2/3\n* Pascal\n* Mono C#/F#/VB\n\nThe judge can also grade in the languages listed below:\n\n* Ada\n* AWK\n* COBOL\n* D\n* Dart\n* Fortran\n* Forth\n* Go\n* Groovy\n* Haskell\n* INTERCAL\n* Kotlin\n* Lean 4\n* LLVM IR\n* Lua\n* NASM\n* Objective-C\n* OCaml\n* Perl\n* PHP\n* Pike\n* Prolog\n* Racket\n* Ruby\n* Rust\n* Scala\n* Chicken Scheme\n* sed\n* Steel Bank Common Lisp\n* Swift\n* Tcl\n* Turing\n* V8 JavaScript\n* Brain\\*\\*\\*\\*\n* Zig\n\n## Installation\n\nInstalling the DMOJ judge creates two executables in your Python's script directory: `dmoj` and `dmoj-cli`.\n`dmoj` is used to connect a judge to a DMOJ site instance, while `dmoj-cli` provides a command-line interface to a\nlocal judge, useful for testing problems.\n\nFor more detailed steps, read the [installation instructions](https://docs.dmoj.ca/#/judge/setting_up_a_judge).\n\nNote that **the only Linux distribution with first-class support is the latest Debian**, with the default `apt` versions of all runtimes. This is [what we run on dmoj.ca](https://dmoj.ca/runtimes/matrix/), 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](https://github.com/DMOJ/judge-server/issues).\n\n### Stable build\n\n[](https://pypi.python.org/pypi/dmoj)\n[](https://pypi.python.org/pypi/dmoj)\n\nWe periodically publish builds [on PyPI](https://pypi.python.org/pypi/dmoj). This is the easiest way to get started,\nbut may not contain all the latest features and improvements.\n\n```\n$ pip install dmoj\n```\n\n### Bleeding-edge build\n\nThis is the version of the codebase we run live on [dmoj.ca](https://dmoj.ca/).\n\n```\n$ git clone --recursive https://github.com/DMOJ/judge-server.git\n$ cd judge-server\n$ pip install -e .\n```\n\nSeveral environment variables can be specified to control the compilation of the sandbox:\n\n* `DMOJ_TARGET_ARCH`; use it to override the default architecture specified for compiling the sandbox (via `-march`).\n Usually this is `native`, but will not be specified on ARM unless `DMOJ_TARGET_ARCH` is set (a generic, slow build will be compiled instead).\n\n### With Docker\n\nWe maintain Docker images with all runtimes we support in the [runtimes-docker](https://github.com/DMOJ/runtimes-docker) project.\n\nRuntimes are split into three tiers of decreasing support. Tier 1 includes\nPython 2/3, C/C++ (GCC only), Java 8, and Pascal. Tier 3 contains all the\nruntimes we run on [dmoj.ca](https://dmoj.ca/). Tier 2 contains some in-between\nmix; read the `Dockerfile` for each tier for details. These images are rebuilt\nand tested every week to contain the latest runtime versions.\n\nThe script below spawns a tier 1 judge image. It expects the relevant\nenvironment variables to be set, the network device to be `enp1s0`, problems\nto be placed under `/mnt/problems`, and judge-specific configuration to be in\n`/mnt/problems/judge.yml`. Note that runtime configuration is already done for you,\nand will be merged automatically into the `judge.yml` provided.\n\n```\n$ git clone --recursive https://github.com/DMOJ/judge-server.git\n$ cd judge-server/.docker\n$ make judge-tier1\n$ exec docker run \\\n --name judge \\\n -p \"$(ip addr show dev enp1s0 | perl -ne 'm@inet (.*)/.*@ and print$1 and exit')\":9998:9998 \\\n -v /mnt/problems:/problems \\\n --cap-add=SYS_PTRACE \\\n -d \\\n --restart=always \\\n dmoj/judge-tier1:latest \\\n run -p15001 -s -c /problems/judge.yml \\\n \"$BRIDGE_ADDRESS\" \"$JUDGE_NAME\" \"$JUDGE_KEY\"\n```\n\n## Usage\n\n### Running a judge server\n\n```\n$ dmoj --help\nusage: dmoj [-h] [-p SERVER_PORT] -c CONFIG [-l LOG_FILE] [--no-watchdog]\n [-a API_PORT] [-A API_HOST] [-s] [-k] [-T TRUSTED_CERTIFICATES]\n [-e ONLY_EXECUTORS | -x EXCLUDE_EXECUTORS] [--no-ansi]\n server_host [judge_name] [judge_key]\n\nSpawns a judge for a submission server.\n\npositional arguments:\n server_host host to connect for the server\n judge_name judge name (overrides configuration)\n judge_key judge key (overrides configuration)\n\noptional arguments:\n -h, --help show this help message and exit\n -p SERVER_PORT, --server-port SERVER_PORT\n port to connect for the server\n -c CONFIG, --config CONFIG\n file to load judge configurations from\n -l LOG_FILE, --log-file LOG_FILE\n log file to use\n --no-watchdog disable use of watchdog on problem directories\n -a API_PORT, --api-port API_PORT\n port to listen for the judge API (do not expose to\n public, security is left as an exercise for the\n reverse proxy)\n -A API_HOST, --api-host API_HOST\n IPv4 address to listen for judge API\n -s, --secure connect to server via TLS\n -k, --no-certificate-check\n do not check TLS certificate\n -T TRUSTED_CERTIFICATES, --trusted-certificates TRUSTED_CERTIFICATES\n use trusted certificate file instead of system\n -e ONLY_EXECUTORS, --only-executors ONLY_EXECUTORS\n only listed executors will be loaded (comma-separated)\n -x EXCLUDE_EXECUTORS, --exclude-executors EXCLUDE_EXECUTORS\n prevent listed executors from loading (comma-\n separated)\n --no-ansi disable ANSI output\n --skip-self-test skip executor self-tests\n```\n\n### Running a CLI judge\n\n```\n$ dmoj-cli --help\nusage: dmoj-cli [-h] -c CONFIG\n [-e ONLY_EXECUTORS | -x EXCLUDE_EXECUTORS]\n [--no-ansi]\n\nSpawns a judge for a submission server.\n\noptional arguments:\n -h, --help show this help message and exit\n -c CONFIG, --config CONFIG\n file to load judge configurations from\n -e ONLY_EXECUTORS, --only-executors ONLY_EXECUTORS\n only listed executors will be loaded (comma-separated)\n -x EXCLUDE_EXECUTORS, --exclude-executors EXCLUDE_EXECUTORS\n prevent listed executors from loading (comma-\n separated)\n --no-ansi disable ANSI output\n --skip-self-test skip executor self-tests\n```\n\n## Documentation\n\nFor info on the problem file format and more, [read the documentation](https://docs.dmoj.ca).\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "The judge component of the DMOJ: Modern Online Judge platform",
"version": "4.0.1",
"split_keywords": [
"online-judge"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5d6724b2e27db2a3bcf5942373a85d0eee37bbffdc7abb90edd5192b7b269c01",
"md5": "43b11bf632ce1803a18ac723edec4540",
"sha256": "ef52e06775a89096026744ec7927c1b697da1d5ec9d0c8e7b3eda81cb3f9372e"
},
"downloads": -1,
"filename": "dmoj-4.0.1.tar.gz",
"has_sig": false,
"md5_digest": "43b11bf632ce1803a18ac723edec4540",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 228724,
"upload_time": "2023-01-28T23:13:38",
"upload_time_iso_8601": "2023-01-28T23:13:38.735773Z",
"url": "https://files.pythonhosted.org/packages/5d/67/24b2e27db2a3bcf5942373a85d0eee37bbffdc7abb90edd5192b7b269c01/dmoj-4.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-28 23:13:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "DMOJ",
"github_project": "judge-server",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"lcname": "dmoj"
}