Skip to main content

Creates an exercise grading container

Project description

mooc-grader-cont i.e. mgcont

Runs a Docker container for grading an exercise in mooc-grader style. This stand-alone project was initiated to accelerate development of automatically assessed exercises for mooc-grader. This command-line tool supports one-liner testing and opening shell for debugging inside grading containers.

There are components that could be shared with mooc-grader but currently are duplicated – it is up to the mooc-grader project to assess if it makes sense to create dependencies to ensure identical grading execution.

Installation

Requires Docker installation. The tool is available from PyPi.

# pip install mgcont

Usage

# mgcont --help
usage: __main__.py [-h] [--receiver] [--cleanup] [-c CONFIG]
                   [-f FILE [FILE ...]] [-d DIR] [--values VALUES] [--debug]

Constructs and runs grading containers to test exercises for mooc-grader. Use
"docker attach mgcont_receiver" to view grading results.

optional arguments:
  -h, --help            show this help message and exit
  --receiver            only start the receiver
  --cleanup             remove any remaining containers and temporary files
  -c CONFIG, --config CONFIG
                        a mooc-grader exercise configuration yaml/json
  -f FILE [FILE ...], --file FILE [FILE ...]
                        a file to submit
  -d DIR, --dir DIR     a directory including the files to submit
  --values VALUES       a yaml/json file to use as posted values, "meta" can
                        be defined to simulate server provided meta-data
  --debug               run a debug shell instead of the configured grading
                        command

When mgcont is run, the system always creates a receiver-container and configures it to receive grading results from other mgcont-commands. When attached to a terminal, the receiver logs every HTTP request until the receiver is stopped with ctrl-c. We recommend to open a second terminal and set it up to display grading results before testing exercises, e.g.

# mgcont --receiver
View with: docker attach mgcont_receiver
# docker attach mgcont_receiver

Then we can use the first terminal to test exercises and the second to view the grading results. For example, following submits a single selected file to the selected exercise for grading. If the exercise is working correctly the result will appear in the receiver terminal.

# mgcont -c exercise01/config.yaml -f /path/my_program.py

In contrast to the previous command, following will not run the configured grading cmd inside the container but rather execute a bash shell and attach to the running container. This allows to e.g. inspect the file system state, run distinct parts of the designed grading process and inspect their outputs, and finally run grade to see how the collected feedback and results are delivered to the receiver terminal.

# mgcont -C exercise01/config.yaml --file /path/my_program.py --debug
Running debug shell instead of the configured cmd. Attach to it with docker.
  cmd:     /exercise/run.sh
  shell:   docker attach infallible_tharp
# docker attach infallible_tharp
root@1b2d5aaccbd3:/submission# ls -al
total 12
drwxr-xr-x 2 1496283 70000 4096 Oct 27 11:45 .
drwxr-xr-x 1 root    root  4096 Oct 27 11:45 ..
-rw-r--r-- 1 1496283 70000  811 Oct 27 11:45 e01_program.py
root@1b2d5aaccbd3:/submission# ls /exercise/
config.yaml  grader_tests.py  tests.py  run.sh	test_config.yaml
root@1b2d5aaccbd3:/submission# capture echo "Results!"
root@1b2d5aaccbd3:/submission# capture echo "TotalPoints: 1"
root@1b2d5aaccbd3:/submission# capture echo "MaxPoints: 2"
root@1b2d5aaccbd3:/submission# grade
root@1b2d5aaccbd3:/submission# exit

The following is a convenience command to clean up temporary directories and any remaining debug containers, receiver container, docker network, and temporary submission files in the current directory (submission_tmp).

# mgcont --cleanup

Tip: it is a good idea to include submission_tmp/ in the .gitignore to avoid accidental commits of temporary files.

Exercise design (for mooc-grader)

The system has been designed to support automated assessment & feedback – most typically for various types of programming exercises but the design is not limiting the exercises to that use only. Along instructional material, the exercise configuration defines post values and/or files that the student submits for grading. The exercise furthermore defines a container -> image that is run for the grading. Various images supporting different programming languages & environments are available under apluslms in GitHub and dockerhub. The following mounts are made for the container

  • /submission = the submitted values and files
  • /exercise = path configured in container -> mount
  • other read-only paths configured in container -> mounts

The exercise runs the configured container -> cmd inside the container. At the end, the grading must HTTP post the results to $REC/container-post. Any containers that inherit from apluslms/grading-base will use a cmd-wrapper that automatically posts the results at the end, unless grading scripts have executed grade to post them before.

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

mgcont-1.0.4.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

mgcont-1.0.4-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file mgcont-1.0.4.tar.gz.

File metadata

  • Download URL: mgcont-1.0.4.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for mgcont-1.0.4.tar.gz
Algorithm Hash digest
SHA256 ce884b9f600bc1f0c4834204d39264e30edb27adc8351559d64b56c5c3ef5116
MD5 c5d58cd2069ca5515741792bb250d2ba
BLAKE2b-256 2e0d0b8e3951c467135e2e2ee50eddd5dd62b80c0d3ba8bd613e5cbcc527f575

See more details on using hashes here.

File details

Details for the file mgcont-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: mgcont-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for mgcont-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c88c44204d28542bf3e823272e16bcb83e7f2ed47a517f93f72c9bfe42f1d452
MD5 3adc673e1f1f346b5ecbbde064f1489d
BLAKE2b-256 ee728d61501727fe46fa09671a6e7038f1fe61c95590de52075389dd2d7a7ea3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page