sio2project / sioworkers

GNU General Public License v3.0
11 stars 22 forks source link

sioworkers

sioworkers is the task runner used by SIO2 - the platform for running algorithmic/competitive programming contests. It handles all kinds of asynchronously run jobs - ranging from compiling submissions, to executing them in a supervised, sandboxed environment.

Installation

$ pip install .      # for production deployments
$ pip install .[dev] # with development dependencies

Tests

All tests in this project are being managed with tox, which is simply invoked by running:

$ tox

in the main directory.

Alternatively you can also invoke all the tests directly.

$ TEST_SANDBOXES=1 NO_JAVA_TESTS=1 NO_SIO2JAIL_TESTS=1 pytest -v .

This allows you to enable/disable sandboxed, Java, and Sio2Jail tests respectively. Note that Sio2Jail requires the CPU performance counters to be exposed to the system to work. This usually isn't the case on VPS servers and on public/free continuous integration services, which will cause the tests to fail. It is recommended to skip testing Sio2Jail in those cases.

Docker

An official Docker image for sioworkers is available on the GitHub Container Registry.

$ docker run --rm \
  --network=sio2-network \
  --cap-add=ALL \
  --privileged \
  -e "SIOWORKERSD_HOST=oioioi" \
  -e "WORKER_ALLOW_RUN_CPU_EXEC=true" \
  -e "WORKER_CONCURRENCY=1" \
  -e "WORKER_RAM=1024" \
  --memory="1152m" \
  --cpus=2.0 \
  ghcr.io/sio2project/sioworkers:latest

Notes:

Equivalent Docker Compose configuration:

version: '3.8'

...

worker:
  image: ghcr.io/sio2project/sioworkers:latest
  deploy:
    resources:
      limits:
        cpus: '2'
        memory: 1152m
  cap_add:
    - ALL
  privileged: true
  environment:
    SIOWORKERSD_HOST: 'web'
    WORKER_ALLOW_RUN_CPU_EXEC: 'true'
    # these *will* override any automatic detection of available
    # memory/cpu cores based on container limits!
    WORKER_CONCURRENCY: '1'
    WORKER_RAM: '1024'

Environment variables

The container exposes two environment variables, from which only SIOWORKERSD_HOST is required.