Giter Site home page Giter Site logo

autograd's Introduction

autograd

autograd is a platform for running autograders to grade PrairieLearn coding questions. autograd is not an autograder -- it is a client which receives grading jobs from PrairieLearn, launches the course's own autograder, and captures the output of the autograder to send back to PrairieLearn.

Course grader repo

The only required file in the course's grader repo is configuration.yml in the root directory of the repo. This file contains the commands to be run by autograd. The required fields are shown below:

grader:
  init_commands:
    # List of commands to be run at startup (working directory $AUTOGRAD_GRADER_ROOT)
  setup_commands:
    # List of commands to be run at the beginning of a grading run (working directory $AUTOGRAD_JOB_DIR)
  grade_command: # Main autograder command (working directory $AUTOGRAD_JOB_DIR)
  grade_timeout: 600 # Timeout in seconds before killing grader process
  cleanup_commands:
    # List of commands to be run at the end of a grading run (working directory $AUTOGRAD_JOB_DIR)

The format of a command in configuration.yml is a list of strings containing the command and its arguments. For example:

["apt-get", "install", "-y", "clang-3.5", "libc++abi-dev", "libc++-dev", "libpng-dev"]

The score of the grading job is the exit code of the grading script. This score should be in the integer range 0-255.

The following environment variables are available to autograd commands:

  • AUTOGRAD_ROOT: Path to autograd root directory (typically /opt/autograd)
  • AUTOGRAD_GRADER_ROOT: Path to the working copy of the grader repo (typically /opt/autograd/_grader)
  • AUTOGRAD_JOB_DIR: Path to the temp directory for the current job (e.g. /opt/autograd/job_933175825) -- not available to init commands as they are not associated with a specific job

Security

Production autograd instances run in a Debian-based Docker container as root, which means that apt-get can be used to install any necessary packages. However, this also means that by default, autograder code will be run as root. It is recommended to run the grader command as an unprivileged user with no read access to anything in $AUTOGRAD_ROOT except for $AUTOGRAD_JOB_DIR, as $AUTOGRAD_ROOT contains the grader repo (which may contain test cases and solutions) as well as $AUTOGRAD_ROOT/_ssh which contains the SSH deploy key for the grader repo.

Add the following commands to the end of init_commands to create such a user autograd-user:

- ["adduser", "--system", "--no-create-home", "autograd-user"]
- ["chmod", "-R", "o-r", "$AUTOGRAD_ROOT"]

Then run the grader in the following manner:

chown -R autograd-user $AUTOGRAD_JOB_DIR
su -c "./grader_command" -s /bin/bash autograd-user

Grading job format

Each grading job is a JSON object written to $AUTOGRAD_JOB_DIR/job_data.json. The following is a minimal grading job:

{
    "gid": "g1", // Grading job ID (string)
    "submission": {
        "submittedAnswer": {
            // Object format determined by PL question server.js
        }
    }
}

Development

Dependencies

  • libgit2 v0.24

Setup

  • Create directory /opt/autograd
  • export AUTOGRAD_ROOT=/opt/autograd
  • Copy configuration.yml to $AUTOGRAD_ROOT and configure values

autograd configuration guidelines

  • Grading, started, and result queue names should be of the form cs225-grade, cs225-started, and cs225-result, with the course code changed appropriately
  • grader_repo.repo_url must be an SSH URL (e.g. [email protected]:...)
  • grader_repo.commit can be any of the following formats:
    • Commit hash
    • Branch name: origin/<branchname> or refs/remotes/origin/<branchname>
    • Tag name: <tagname> or refs/tags/<tagname>

Running with Docker

docker run -it --rm --name autograd \
    -v '/absolute/path/to/configuration.yml:/opt/autograd/_conf/configuration.yml' \
    -v '/absolute/path/to/deploy_key:/opt/autograd/_ssh/ssh-privatekey' \
    -v '/absolute/path/to/deploy_key.pub:/opt/autograd/_ssh/ssh-publickey' \
     prairielearn/autograd

autograd's People

Contributors

kevinwang avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.