Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles committed Oct 23, 2022
1 parent d2c1e69 commit 8ef2b41
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 114 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:

env:
TAR: /bin/tar
DOCKER_BUILDKIT: 1

steps:
- name: Set up Python 3.8
Expand All @@ -29,20 +28,6 @@ jobs:
- uses: actions/checkout@v2

- uses: docker/setup-buildx-action@v1
id: buildx
with:
install: true

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v1

- name: Install dependencies
run: |
python3 -m pip install -r requirements.txt twine wheel setuptools
Expand Down Expand Up @@ -94,14 +79,3 @@ jobs:
run: |
hub pull-request -b ucbds-infra:master -h ucbds-infra:stable -l "release" -r chrispyles \
-m "Release v${{ github.event.inputs.version }}"$'\n'$'\n'"Updates from the release of version ${{ github.event.inputs.version }}"
- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
ucbdsinfra/otter-grader:v${{ github.event.inputs.version }}
ucbdsinfra/otter-grader:latest
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ gs-testing-stuff
.OTTER_LOG
docs/tutorial/dist
docs/_static/notebooks/html
arm-Dockerfile
htmlcov/
.pytest_cache/
/sync.sh
27 changes: 27 additions & 0 deletions docs/_static/python_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

export DEBIAN_FRONTEND=noninteractive
apt-get clean
apt-get update
apt-get install -y wget pandoc texlive-xetex texlive-fonts-recommended texlive-plain-generic \
build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev libgit2-dev texlive-lang-chinese

# install conda
if [ $(uname -p) = "arm" ] || [ $(uname -p) = "aarch64" ] ; \
then wget -nv https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh \
-O /autograder/source/miniconda_install.sh ; \
else wget -nv https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
-O /autograder/source/miniconda_install.sh ; \
fi
chmod +x /autograder/source/miniconda_install.sh
/autograder/source/miniconda_install.sh -b
echo "export PATH=/root/miniconda3/bin:\$PATH" >> /root/.bashrc

export PATH=/root/miniconda3/bin:$PATH
export TAR="/bin/tar"

# install dependencies with conda
conda env create -f /autograder/source/environment.yml

# set conda shell
conda init --all
36 changes: 36 additions & 0 deletions docs/_static/r_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

export DEBIAN_FRONTEND=noninteractive
apt-get clean
apt-get update
apt-get install -y wget pandoc texlive-xetex texlive-fonts-recommended texlive-plain-generic \
build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev libgit2-dev texlive-lang-chinese
apt-get install -y libnlopt-dev cmake libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev \
apt-utils libpoppler-cpp-dev libavfilter-dev libharfbuzz-dev libfribidi-dev imagemagick \
libmagick++-dev pandoc texlive-xetex texlive-fonts-recommended texlive-plain-generic \
build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev libgit2-dev texlive-lang-chinese \
libxft-dev

# install conda
if [ $(uname -p) = "arm" ] || [ $(uname -p) = "aarch64" ] ; \
then wget -nv https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh \
-O /autograder/source/miniconda_install.sh ; \
else wget -nv https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
-O /autograder/source/miniconda_install.sh ; \
fi
chmod +x /autograder/source/miniconda_install.sh
/autograder/source/miniconda_install.sh -b
echo "export PATH=/root/miniconda3/bin:\$PATH" >> /root/.bashrc

export PATH=/root/miniconda3/bin:$PATH
export TAR="/bin/tar"

# install dependencies with conda
conda env create -f /autograder/source/environment.yml
conda run -n otter-env Rscript /autograder/source/requirements.r

# set conda shell
conda init --all

# install ottr; not sure why it needs to happen twice but whatever
conda run -n otter-env Rscript -e 'install.packages("https://cran.r-project.org/src/contrib/Archive/ottr/ottr_1.1.5.tar.gz", dependencies=TRUE, repos=NULL)'
22 changes: 20 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import os
import sys
import yaml

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand All @@ -24,6 +23,7 @@
import nbconvert

from glob import glob
from jinja2 import Template
from otter.generate import CondaEnvironment
from otter.utils import print_full_width

Expand Down Expand Up @@ -112,7 +112,7 @@
# a list of builtin themes.
#
html_theme = 'sphinx_book_theme'
html_logo = '../logo/otter-logo-smaller.png'
html_logo = '../logo/otter-logo-smallest.png'

html_theme_options = {
'github_url': 'https://github.com/ucbds-infra/otter-grader',
Expand Down Expand Up @@ -222,11 +222,29 @@ def convert_static_notebooks():
print_full_width("=")


def make_setup_sh_files():
ctx = {
"autograder_dir": "/autograder",
"otter_env_name": "otter-env",
"has_r_requirements": True,
}

for l in ["python", "r"]:
with open(f"../otter/generate/templates/{l}/setup.sh") as f:
t = Template(f.read())
s = t.render(ctx)
with open(f"_static/{l}_setup.sh", "w+") as f:
f.write(s)


# -- Extension configuration -------------------------------------------------
def setup(app):
# run nbconvert on all of the notebooks in _static/notebooks
convert_static_notebooks()

# convert templates to valid setup.sh files
make_setup_sh_files()

with open("_static/grading-environment.yml", "w+") as f:
f.write(CondaEnvironment(3.7, False, [], False, None).to_str())

Expand Down
24 changes: 5 additions & 19 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,18 @@ Installation

Otter is a Python package that is compatible with Python 3.6+. The PDF export internals require
either LaTeX and Pandoc or wkhtmltopdf to be installed. Docker is also required to grade assignments
locally with containerization, and Postgres only if you're using Otter Service. Otter's Python
package can be installed using pip. To install the current stable version, install with
locally with containerization. Otter's Python package can be installed using pip. To install the
current stable version, install with

.. code-block:: console
pip install otter-grader
If you are going to be autograding R, you must also install the R package using
``devtools::install_github``:

.. code-block:: r
devtools::install_github("ucbds-infra/ottr@stable")
Installing the Python package will install the ``otter`` binary so that Otter can be called from the
command line. You can also call Otter as a Python module with ``python3 -m otter``.

If you are going to be autograding R, you must also install the R package ``ottr``:

Docker
++++++

Otter uses Docker to create containers in which to run the students' submissions. **Docker and our
Docker image are only required if using Otter Grade.** Please make sure that you
install Docker and pull our Docker image, which is used to grade the notebooks. To get the Docker
image, run

.. code-block:: console
.. code-block:: r
docker pull ucbdsinfra/otter-grader
install.packages("ottr")
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sphinx_markdown_tables
sphinx-book-theme==0.1.7
sphinx-book-theme==0.3.3
sphinxcontrib-apidoc
sphinx-click
jinja2
24 changes: 9 additions & 15 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ Otter Assign on this notebook, run

.. code-block:: console
$ otter assign demo.ipynb dist
Generating views...
Generating solutions PDF...
Generating autograder zipfile...
Running tests...
All tests passed!
otter assign demo.ipynb dist
Otter Assign should create a ``dist`` directory which contains two further subdirectories:
``autograder`` and ``student``. The ``autograder`` directory contains the Gradescope autograder,
Expand Down Expand Up @@ -101,16 +96,15 @@ machine. You can also grade on Gradescope or without containerization, as descri

Let's now construct a call to Otter that will grade these notebooks. We will use
``dist/autograder/autograder.zip`` from running Otter Assign to configure our grading image. Our notebooks
are in the ``ipynbs`` subdirectory, so we'll need to use the ``-p`` flag. The notebooks also contain
a couple of written questions, and the :ref:`filtering <pdfs>` is implemented using HTML comments, so
are in the ``ipynbs`` subdirectory and contain a couple of written questions, so
we'll specify the ``--pdfs`` flag to indicate that Otter should grab the PDFs out of the Docker
containers.
containers. Lastly, we'll name the assignment ``demo`` with the ``-n`` flag.

Let's run Otter on the notebooks:

.. code-block:: console
otter grade -p submissions/ipynbs -a dist/autograder/demo-autograder_*.zip --pdfs -v
otter grade -n demo -a dist/autograder/demo-autograder_*.zip --pdfs -v submissions/ipynbs
(The ``-v`` flag so that we get verbose output.) After this finishes running, there
should be a new file and a new folder in the working directory: ``final_grades.csv`` and
Expand Down Expand Up @@ -168,16 +162,16 @@ The latter, the ``submission_pdfs`` directory, should contain the filtered PDFs
Otter Grade can also grade the zip file exports provided by the ``Notebook.export`` method. Before
grading the zip files, you must edit your ``autograder.zip`` to indicate that you're doing so. To
do this, open ``demo.ipynb`` (the file we used with Otter Assign) and edit the first cell of the
notebook (beginning with ``BEGIN ASSIGNMENT``) so that the ``zips`` key under ``generate`` is
notebook (beginning with ``# ASSIGNMENT CONFIG``) so that the ``zips`` key under ``generate`` is
``true`` in the YAML and rerun Otter Assign.

Now, all we need to do is add the ``-z`` flag to the call to indicate that you're grading these zip
files. We have provided some, with the same notebooks as above, in the ``zips`` directory, so let's
grade those:
Now, all we need to do is add the ``--ext`` flag to indicate that the submissions are zip files.
We have provided some example submissions, with the same notebooks as above, in the ``zips``
directory, so let's grade those:

.. code-block:: console
otter grade -p submissions/zips -a dist/autograder/demo-autograder_*.zip -vz
otter grade -n demo -a dist/autograder/demo-autograder_*.zip -v --ext zip submissions/zips
This should have the same CSV output as above but no ``submission_pdfs`` directory since we didn't
tell Otter to generate PDFs.
Expand Down
Loading

0 comments on commit 8ef2b41

Please sign in to comment.