Skip to content

Commit

Permalink
Merge pull request #335 from chrispyles/remove-pdfs-key
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles authored Aug 25, 2021
2 parents 5871100 + e2c3902 commit cbceb78
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 59 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Fix some minor bugs using docker for grading
* Added support for test config blocks in R assignments
* Fixed use of `autograder_files` in Otter Assign
* Removed the `generate: pdfs` key from Otter Assign assignment configurations
* Converted from Docker-py to Python on Whales for containerized grading

**v3.0.2:**

Expand Down
20 changes: 16 additions & 4 deletions docs/otter_assign/v0/python_notebook_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,28 @@ their values:
show_hidden: true
You can also set the autograder up to automatically upload PDFs to student submissions to another
Gradescope assignment by setting the necessary keys in the ``pdfs`` subkey of ``generate``:
Gradescope assignment by setting the necessary keys in ``generate``:

.. code-block:: yaml
generate:
pdfs:
token: YOUR_GS_TOKEN # required
token: ''
course_id: 1234 # required
assignment_id: 5678 # required
filtering: true # true is the default
If you don't specify a token, you will be prompted for your username and password when you run Otter
Assign; optionally, you can specify these via the command line with the ``--username`` and
``--password`` flags. You can also run the following to retrieve your token:

.. code-block:: python
from otter.generate.token import APIClient
print(APIClient.get_token())
Any configurations in your ``generate`` key will be put into an ``otter_config.json`` and used when
running Otter Generate.

If you are grading from the log or would like to store students' environments in the log, use the
``save_environment`` key. If this key is set to ``true``, Otter will serialize the stuednt's
environment whenever a check is run, as described in :ref:`logging`. To restrict the
Expand All @@ -146,7 +157,8 @@ cell, and passes the configurations ``points`` and ``seed`` to Otter Generate vi
```
BEGIN ASSIGNMENT
filtering: false
export_cell:
filtering: false
init_cell: false
generate:
points: 3
Expand Down
24 changes: 18 additions & 6 deletions docs/otter_assign/v1/notebook_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,22 @@ Gradescope assignment by setting the necessary keys in the ``pdfs`` subkey of ``
.. code-block:: yaml
generate:
pdfs:
token: YOUR_GS_TOKEN # required
course_id: 1234 # required
assignment_id: 5678 # required
filtering: true # true is the default
token: ''
course_id: 1234 # required
assignment_id: 5678 # required
filtering: true # true is the default
If you don't specify a token, you will be prompted for your username and password when you run Otter
Assign; optionally, you can specify these via the command line with the ``--username`` and
``--password`` flags. You can also run the following to retrieve your token:

.. code-block:: python
from otter.generate.token import APIClient
print(APIClient.get_token())
Any configurations in your ``generate`` key will be put into an ``otter_config.json`` and used when
running Otter Generate.

If you are grading from the log or would like to store students' environments in the log, use the
``save_environment`` key. If this key is set to ``true``, Otter will serialize the stuednt's
Expand All @@ -146,7 +157,8 @@ cell, and passes the configurations ``points`` and ``seed`` to Otter Generate vi
.. code-block:: yaml
# ASSIGNMENT CONFIG
filtering: false
export_cell:
filtering: false
init_cell: false
generate:
points: 3
Expand Down
20 changes: 4 additions & 16 deletions otter/assign/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,28 +234,16 @@ def run_generate_autograder(result, assignment, gs_username, gs_password, plugin
if generate_args is True:
generate_args = {}

if "pdfs" in generate_args:
raise ValueError("The 'pdfs' key of 'generate' is no longer supported. Put any " + \
"'pdfs' configurations inside the 'generate' key itself.")

if assignment.is_r:
generate_args["lang"] = "r"

curr_dir = os.getcwd()
os.chdir(str(result / 'autograder'))

# TODO: make it so pdfs is not a key in the generate key, but matches the structure expected by
# run_autograder
if generate_args.get('pdfs', {}):
pdf_args = generate_args.pop('pdfs', {})
generate_args['course_id'] = str(pdf_args['course_id'])
generate_args['assignment_id'] = str(pdf_args['assignment_id'])

if pdf_args.get("token"):
generate_args['token'] = str(pdf_args['token'])

if not pdf_args.get("filtering", True):
generate_args['filtering'] = False

if not pdf_args.get('pagebreaks', True):
generate_args['pagebreaks'] = False

# use temp tests dir
test_dir = "tests"
if assignment.is_python and not assignment.test_files and assignment._temp_test_dir is None:
Expand Down
20 changes: 4 additions & 16 deletions otter/assign/v0/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,25 +214,13 @@ def run_generate_autograder(result, assignment, gs_username, gs_password, plugin
if assignment.is_r:
generate_args["lang"] = "r"

if "pdfs" in generate_args:
raise ValueError("The 'pdfs' key of 'generate' is no longer supported. Put any " + \
"'pdfs' configurations inside the 'generate' key itself.")

curr_dir = os.getcwd()
os.chdir(str(result / 'autograder'))

# TODO: make it so pdfs is not a key in the generate key, but matches the structure expected by
# run_autograder
if generate_args.get('pdfs', {}):
pdf_args = generate_args.pop('pdfs', {})
generate_args['course_id'] = str(pdf_args['course_id'])
generate_args['assignment_id'] = str(pdf_args['assignment_id'])

if pdf_args.get("token"):
generate_args['token'] = str(pdf_args['token'])

if not pdf_args.get("filtering", True):
generate_args['filtering'] = False

if not pdf_args.get('pagebreaks', True):
generate_args['pagebreaks'] = False

# use temp tests dir
test_dir = "tests"
if assignment.is_python and not assignment.test_files and assignment._temp_test_dir is None:
Expand Down
16 changes: 7 additions & 9 deletions test/test-assign/generate-gradescope.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
" seed: 42\n",
" show_stdout: true\n",
" show_hidden: true\n",
" pdfs:\n",
" token: 'token123'\n",
" course_id: '123'\n",
" class_id: '1234'\n",
" assignment_id: '567'\n",
" filtering: true\n",
" token: 'token123'\n",
" course_id: '123'\n",
" assignment_id: '567'\n",
" filtering: true\n",
"colab: true\n",
"files:\n",
" - data.csv\n",
Expand Down Expand Up @@ -587,7 +585,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.7"
},
"varInspector": {
"cols": {
Expand Down Expand Up @@ -620,5 +618,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
}
"nbformat_minor": 4
}
3 changes: 2 additions & 1 deletion test/test-assign/gs-autograder-correct/otter_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"seed": 42,
"show_stdout": true,
"show_hidden": true,
"token": "token123",
"course_id": "123",
"assignment_id": "567",
"token": "token123"
"filtering": true
}
Binary file modified test/test-assign/gs-correct/autograder/autograder.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.7"
},
"otter": {
"tests": {
Expand Down Expand Up @@ -619,5 +619,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
}
"nbformat_minor": 4
}
3 changes: 2 additions & 1 deletion test/test-assign/gs-correct/autograder/otter_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"seed": 42,
"show_stdout": true,
"show_hidden": true,
"token": "token123",
"course_id": "123",
"assignment_id": "567",
"token": "token123"
"filtering": true
}
6 changes: 3 additions & 3 deletions test/test-assign/gs-correct/student/generate-gradescope.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.7"
},
"otter": {
"tests": {
Expand Down Expand Up @@ -519,5 +519,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
}
"nbformat_minor": 4
}

0 comments on commit cbceb78

Please sign in to comment.