Skip to content

Commit

Permalink
Merge pull request #669 from ucbds-infra/beta
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles committed Jul 18, 2023
2 parents 1a72d46 + 8dbccac commit bc005f0
Show file tree
Hide file tree
Showing 467 changed files with 5,687 additions and 8,481 deletions.
3 changes: 0 additions & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@ omit =

# This file is a copy of an external script and is not tested as part of Otter
otter/plugins/builtin/gmail_notifications/bin/gmail_oauth2.py

# The Assign v0 format is deprecated and will be removed in v5
otter/assign/v0/*
46 changes: 0 additions & 46 deletions .github/workflows/docker-build.yml

This file was deleted.

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
18 changes: 6 additions & 12 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,24 @@ jobs:

env:
TAR: /bin/tar
DOCKER_BUILDKIT: 1
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: enabled

steps:
- uses: actions/checkout@v2

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

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

- name: Prepare for Docker image build
run: |
make docker-test-prepare
- name: Build Docker image
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
file: test-Dockerfile
load: true
push: false
tags: otter-test
Expand All @@ -51,11 +46,10 @@ jobs:
build-args: |
DOCKER_VERSION=20.10.24
- name: Clean up Docker image build
run: make docker-ci-test-cleanup

- name: Run tests
run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp otter-test bash -c "cd /home/otter-grader; pip install -r requirements-test.txt -r requirements-export.txt; make testcov && coverage xml -i && cp ./coverage.xml /tmp/coverage.xml" && cp /tmp/coverage.xml ./coverage.xml
run: |
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp otter-test /root/otter-grader/bin/run_tests
cp /tmp/coverage.xml ./coverage.xml
- uses: codecov/codecov-action@v3
with:
Expand Down
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
8 changes: 0 additions & 8 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@ version: 2
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7

conda:
environment: rtd_environment.yml
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

**Unreleased (beta):**

* Converted all dependency management in the autograder configuration zip file to Conda per [#501](https://github.com/ucbds-infra/otter-grader/issues/501)
* Removed deprecated Otter Assign format v0
* Disabled editing for question prompt cells in the notebooks generated by Otter Assign per [#431](https://github.com/ucbds-infra/otter-grader/issues/431)
* Removed `ucbdsinfra/otter-grader` Docker image and made default image for Otter Grade `ubuntu:22.04` per [#534](https://github.com/ucbds-infra/otter-grader/issues/534)
* Make `xeCJK` opt-in behavior for exporting notebooks via LaTeX per [#548](https://github.com/ucbds-infra/otter-grader/issues/548)
* Convert from use of deprecated `PyPDF2` package to `pypdf`
* Add configuration to submit blank PDF to manual-grading Gradescope assignment if PDF generation fails per [#551](https://github.com/ucbds-infra/otter-grader/issues/551)
* Removed the `after_execution` event from the plugin lifecycle
* Updated execution internals to use `nbconvert.preprocessors.ExecutePreprocessor` instead of the `exec` function to execute submissions per [#604](https://github.com/ucbds-infra/otter-grader/issues/604)
* Deprecated the `variables` key of the assignment config in favor of `generate.serialized_variables`
* Enabled Otter Generate for all assignments created with Otter Assign
* Updated Otter Assign to use Otter Run to validate that all tests in the assignment pass, allowing tests to be run for R assignments as well as Python, per [#427](https://github.com/ucbds-infra/otter-grader/issues/427)
* Allow Markdown cells to be used instead of raw cells for Otter Assign per [#592](https://github.com/ucbds-infra/otter-grader/issues/592)
* Use Otter Grade CLI flags to update `otter_config.json` values in the grading container per [#395](https://github.com/ucbds-infra/otter-grader/issues/395)
* Removed `linux/amd64` platform specification for Docker images in Otter Grade
* Updated Otter Assign to normalize notebooks before writing them with `nbformat.validator.normalize` per [#658](https://github.com/ucbds-infra/otter-grader/issues/658)
* Added summary of assignment questions to Otter Assign logging per [#564](https://github.com/ucbds-infra/otter-grader/issues/564)
* Converted to Mamba from Conda for package management in grading containers per [#660](https://github.com/ucbds-infra/otter-grader/issues/660)
* Upgraded default Python version in grading containers from 3.7 to 3.9

**v4.4.1:**

* Update Otter Grade to close file handles before copying files out of Docker containers to fix bug on Windows
Expand Down
27 changes: 0 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,6 @@ make testcov
```


### Test Docker Images

To build a Docker image suitable for testing, use the Makefile target `docker-test`. This will
build a Docker image tagged `otter-test` which includes the development version of Otter in your
local copy of the repo as the installed version of Otter.

```
make docker-test
```

If you need to build testing images for grading assignments, use the `docker-grade-test` target to
edit the Dockerfile in `otter/grade` and then install your local copy of the rpeo:

```
make docker-grade-test
pip install .
```

**Do not commit any changes made by this Makefile target.**

Once you finish, make sure to run the `cleanup-docker-grade-test` target to undo your changes.

```
make cleanup-docker-grade-test
```


## Building the Documentation

To build a local copy of the documentation, use the `docs` target of the Makefile.
Expand Down
89 changes: 33 additions & 56 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,56 +1,33 @@
# Dockerfile forked from https://github.com/jeffheaton/docker-jupyter-python-r/blob/master/Dockerfile
FROM ubuntu:20.04

# common packages
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y tzdata git vim wget libssl-dev nano && \
rm -rf /var/lib/apt/lists/*

# miniconda
RUN echo 'export PATH=/opt/conda/bin:$PATH' >> /root/.bashrc && \
wget --quiet https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
rm -rf /var/lib/apt/lists/*

ENV PATH /opt/conda/bin:$PATH

# R pre-reqs
RUN apt-get clean && \
apt-get update && \
apt-get install -y --no-install-recommends fonts-dejavu gfortran gcc && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# R
RUN apt-get clean && \
apt-get update && \
conda install -y "r-base>=4.0.0" r-essentials && \
conda install -c r r-irkernel r-essentials r-devtools -c conda-forge && \
rm -rf /var/lib/apt/lists/*

# install wkhtmltopdf for otter export
RUN apt-get clean && \
apt-get update && \
apt-get install -y pandoc && \
apt-get install -y -f texlive-xetex texlive-fonts-recommended texlive-lang-chinese && \
wget --quiet -O /tmp/wkhtmltopdf.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb && \
apt-get install -y /tmp/wkhtmltopdf.deb && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Set the locale to UTF-8 to ensure that Unicode output is encoded correctly
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

# create dir for autograder
RUN mkdir /autograder

# Python requirements
ADD requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt

RUN pip install otter-grader==4.4.1
RUN Rscript -e "install.packages('ottr', dependencies=TRUE, repos='http://cran.us.r-project.org')"
# Docker image for setting up a development environment and Otter's automated tests.

FROM docker/buildx-bin as buildx

FROM ubuntu:latest

# Make docker buildx available in the container
COPY --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx

# Install apt packages
RUN apt-get update && apt-get upgrade -y && apt-get install -y wget make build-essential

# Install mamba
RUN if [ $(uname -p) = "arm" ] || [ $(uname -p) = "aarch64" ] ; \
then wget -nv https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-aarch64.sh \
-O /tmp/mamba_install.sh ; \
else wget -nv https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh \
-O /tmp/mamba_install.sh ; \
fi && \
chmod +x /tmp/mamba_install.sh && \
/tmp/mamba_install.sh -b
ENV PATH=/root/mambaforge/bin:$PATH

# Create mamba environment
COPY environment.yml requirements.txt requirements-export.txt requirements-test.txt /tmp/
RUN mkdir -p /tmp/docs && touch /tmp/docs/requirements.txt
RUN mamba env create -f /tmp/environment.yml
RUN mamba run -n otter-grader Rscript -e 'install.packages("ottr", dependencies=TRUE, repos="https://cran.r-project.org")'
ADD . /root/otter-grader
RUN mamba run -n otter-grader pip install /root/otter-grader

# Make script executable
RUN chmod +x /root/otter-grader/bin/run_tests
38 changes: 0 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ PYTESTOPTS = -v
COVERAGE = coverage
DOCKER = true
SLOW = true
OS := $(shell uname -s)

ifeq ($(DOCKER), false)
PYTESTOPTS := $(PYTESTOPTS) -m "not docker"
Expand All @@ -28,45 +27,8 @@ htmlcov: testcov
docs:
$(MAKE) -C docs html

docker-test-prepare:
cp -r Dockerfile test-Dockerfile
printf "\nADD . /home/otter-grader\nRUN pip install /home/otter-grader" >> test-Dockerfile
printf "\nARG DOCKER_VERSION" >> test-Dockerfile
printf "\nRUN cd /tmp && curl -sSL -O https://download.docker.com/linux/static/stable/x86_64/docker-$$%s.tgz && tar zxf docker-$$%s.tgz && mv ./docker/docker /usr/local/bin && chmod +x /usr/local/bin/docker && rm -rf /tmp/*" "{DOCKER_VERSION}" "{DOCKER_VERSION}" >> test-Dockerfile
printf "\nCOPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx" >> test-Dockerfile
printf "\nENV PYTHONUNBUFFERED 1" >> test-Dockerfile

docker-test: docker-test-prepare
docker build . -t otter-test -f test-Dockerfile --cache-from ucbdsinfra/otter-grader:latest
rm test-Dockerfile

docker-ci-test-cleanup:
rm test-Dockerfile

tutorial:
cd docs/tutorial; \
zip -r tutorial.zip submissions demo.ipynb requirements.txt -x "*.DS_Store"; \
cp tutorial.zip ../_static; \
rm tutorial.zip

docker-grade-test:
cp otter/generate/templates/python/setup.sh otter/generate/templates/python/old-setup.sh
printf "\nconda run -n otter-env pip install /home/otter-grader" >> otter/generate/templates/python/setup.sh
ifeq ($(OS), Darwin)
sed -i '' -e "s+ucbdsinfra/otter-grader+otter-test+" otter/generate/templates/python/setup.sh
sed -i '' -e "s+ucbdsinfra/otter-grader+otter-test+" otter/generate/templates/python/run_autograder
else
sed -i "s+ucbdsinfra/otter-grader+otter-test+" otter/generate/templates/python/setup.sh
sed -i "s+ucbdsinfra/otter-grader+otter-test+" otter/generate/templates/python/run_autograder
endif

cleanup-docker-grade-test:
rm otter/generate/templates/python/setup.sh
mv otter/generate/templates/python/old-setup.sh otter/generate/templates/python/setup.sh
ifeq ($(OS), Darwin)
sed -i '' -e "s+otter-test+ucbdsinfra/otter-grader+" otter/generate/templates/python/setup.sh
sed -i '' -e "s+otter-test+ucbdsinfra/otter-grader+" otter/generate/templates/python/run_autograder
else
sed -i "s+otter-test+ucbdsinfra/otter-grader+" otter/generate/templates/python/setup.sh
sed -i "s+otter-test+ucbdsinfra/otter-grader+" otter/generate/templates/python/run_autograder
endif
11 changes: 11 additions & 0 deletions bin/run_tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Runs Otter's tests and copies the resulting coverage.xml file into the /tmp directory. This script
# should only be used inside a Docker container created by /Dockerfile.

export PATH="/root/mambaforge/bin:$PATH"
source /root/mambaforge/etc/profile.d/conda.sh
source /root/mambaforge/etc/profile.d/mamba.sh
cd /root/otter-grader
mamba activate otter-grader
make testcov PYTESTOPTS="-vv" && coverage xml -i && cp ./coverage.xml /tmp/coverage.xml
Loading

0 comments on commit bc005f0

Please sign in to comment.