Skip to content

Commit

Permalink
Add pip install cell to Colab notebooks (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles authored Oct 15, 2024
1 parent cb84608 commit 7fbb47f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* Updated Otter Grade Docker image to create an empty `submission_metadata.json` file in the grading image to prevent plugins from erroring per [#811](https://github.com/ucbds-infra/otter-grader/issues/811)
* Added ability to monitor grading progress to Otter Grade per [#827](https://github.com/ucbds-infra/otter-grader/issues/827)
* Added handling of student-created files with the `student_files` configuration in Otter Assign per [#737](https://github.com/ucbds-infra/otter-grader/issues/737)
* Updated Otter Assign to add a cell to install Otter at the top of Colab notebooks per [#861](https://github.com/ucbds-infra/otter-grader/issues/861)

**v5.7.1:**

Expand Down
9 changes: 8 additions & 1 deletion otter/assign/cell_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ def create_init_cells(self) -> list[nbformat.NotebookNode]:
contents = f"# Initialize Otter\nimport otter\ngrader = otter.Notebook({args})"
cell = nbformat.v4.new_code_cell(contents)
lock(cell)
return [cell]

extra_cells = []
if self.assignment.runs_on == "colab":
pip_cell = nbformat.v4.new_code_cell("%pip install -q otter-grader")
lock(pip_cell)
extra_cells.append(pip_cell)

return extra_cells + [cell]

def create_check_cells(self, question: QuestionConfig) -> list[nbformat.NotebookNode]:
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"deletable": false,
"editable": false
},
"outputs": [],
"source": [
"%pip install -q otter-grader"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"deletable": false,
"editable": false
},
"outputs": [],
"source": [
"%pip install -q otter-grader"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 7fbb47f

Please sign in to comment.