Skip to content

Commit 511f1cf

Browse files
committed
add start of Gradescope autograder
1 parent d9fa721 commit 511f1cf

File tree

10 files changed

+88
-36
lines changed

10 files changed

+88
-36
lines changed

.gitignore

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,4 @@ Untitled.ipynb
1515
# override the global
1616
!.vscode/settings.json
1717

18-
## Terraform ##
19-
20-
# Local .terraform directories
21-
**/.terraform/*
22-
23-
# .tfstate files
24-
*.tfstate
25-
*.tfstate.*
26-
27-
# Crash log files
28-
crash.log
29-
30-
# Exclude all .tfvars files, which are likely to contain sentitive data, such as
31-
# password, private keys, and other secrets. These should not be part of version
32-
# control as they are data points which are potentially sensitive and subject
33-
# to change depending on the environment.
34-
#
35-
*.tfvars
36-
37-
# Ignore override files as they are usually used to override resources locally and so
38-
# are not checked in
39-
override.tf
40-
override.tf.json
41-
*_override.tf
42-
*_override.tf.json
43-
44-
# Include override files you do wish to add to version control using negated pattern
45-
#
46-
# !example_override.tf
47-
48-
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
49-
# example: *tfplan*
50-
51-
# Ignore CLI configuration files
52-
.terraformrc
53-
terraform.rc
18+
extras/autograder/results/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gradescope_utils
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
# based on
4+
# https://github.com/gradescope/autograder_samples/blob/master/python/src/run_autograder
5+
6+
set -ex
7+
8+
cd /autograder/source
9+
10+
python3 run_tests.py
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""based on https://github.com/gradescope/autograder_samples/blob/master/python/src/run_tests.py"""
2+
3+
import unittest
4+
from gradescope_utils.autograder_utils.json_test_runner import JSONTestRunner
5+
6+
if __name__ == '__main__':
7+
suite = unittest.defaultTestLoader.discover('tests')
8+
with open('/autograder/results/results.json', 'w') as f:
9+
JSONTestRunner(visibility='visible', stream=f).run(suite)

extras/autograder/source/setup.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
apt-get install -y python3 python3-pip
6+
7+
pip3 install -r /autograder/source/requirements.txt
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import unittest
2+
from gradescope_utils.autograder_utils.decorators import weight, number
3+
4+
5+
class TestSimpleArithmetic(unittest.TestCase):
6+
@weight(1)
7+
@number("1.1")
8+
def test_eval_add(self):
9+
"""Evaluate 1 + 1"""
10+
self.assertEqual(1+1, 2)

extras/autograder/submission/example.ipynb

Whitespace-only changes.

extras/autograder/submission/example.py

Whitespace-only changes.

extras/terraform/.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# Crash log files
9+
crash.log
10+
11+
# Exclude all .tfvars files, which are likely to contain sentitive data, such as
12+
# password, private keys, and other secrets. These should not be part of version
13+
# control as they are data points which are potentially sensitive and subject
14+
# to change depending on the environment.
15+
#
16+
*.tfvars
17+
18+
# Ignore override files as they are usually used to override resources locally and so
19+
# are not checked in
20+
override.tf
21+
override.tf.json
22+
*_override.tf
23+
*_override.tf.json
24+
25+
# Include override files you do wish to add to version control using negated pattern
26+
#
27+
# !example_override.tf
28+
29+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
30+
# example: *tfplan*
31+
32+
# Ignore CLI configuration files
33+
.terraformrc
34+
terraform.rc

meta/instructor_guide.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ Most of the issues are around Plotly rendering. Things that have been hit repeat
124124

125125
- Comments in [`environment.yml`](https://github.com/afeld/python-public-policy/blob/main/extras/environment.yml)
126126
- [Student troubleshooting guide](../assignments.md#common-issues)
127+
128+
## Autograder
129+
130+
Based on the [Gradescope instructions](https://gradescope-autograders.readthedocs.io/en/latest/manual_docker/):
131+
132+
```sh
133+
cd extras/autograder
134+
mkdir -p results
135+
136+
docker run --rm \
137+
-v .:/autograder \
138+
gradescope/autograder-base \
139+
/bin/bash -c "/autograder/source/setup.sh && /autograder/source/run_autograder"
140+
141+
cat results/results.json
142+
```
127143
{%- endif %}
128144

129145
## Contacts

0 commit comments

Comments
 (0)