Warning: Consider the code pre-alpha stage quality, use it with caution.
- Okpy compatible autograder that uses Gofer Grader underneath
- It is built for Data100 course at Berkeley.
-
If you have a jupyter assignment that only requires small (as in <100MB) dataset, you should use okpy.org autograder service.
-
This service is built to accommodate large scale grading that also depends on big dataset.
- The autograding scale-out is implemented by Kubernetes Jobs
- This means you need a jupyterhub kubernetes cluster running in the first place and the jupyterhub cluster should have access to all the necessary data.·
- This repo contains an okpy compatible api server that can receives task from okpy and spawn kubernetes jobs.·
- To use it, you need to build a docker container on top of your jupyterhub container, and configure
GradingJobConfig.yml
accordingly. - Install dependency and start the webserver by
run.sh
-
Create an Ubuntu 18.04 VM within the same project that your Kubernetes Jupyterhub environment is running in.
gcloud compute instances create grader \ --image=ubuntu-1804-bionic-v20190514 \ --image-project=ubuntu-os-cloud \ --scopes https://www.googleapis.com/auth/gerritcodereview \ --machine-type=n1-standard-1 \ --project=<PROJECT_ID> \ --tags=autograder
-
Create ingress rule for port 8000 ( Limit the source IP Addresses to a small list )
gcloud compute firewall-rules create autograder \ --network default \ --direction ingress \ --priority 1000 \ --action allow \ --target-tag autograder \ --source-ranges [CIDR-RANGE] \ --rules tcp:8000
-
Install the following packages on the grader instance
- docker, python 3.6 , pip3
snap install docker snap start docker sudo apt update && sudo apt install python3-pip
-
Link /usr/bin/python with /usr/bin/python3
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
-
Install python modules in requirements.txt file
pip3 install -r requirements.txt
-
Restart your shell to update your environment
-
Clone the Pandas-grader git repository
git clone https://github.com/DS-100/Pandas-Grader.git
-
Edit the GradingJobConfig.yml file
- Search for "image"and modify the image name with your single-user image.
-
Edit the app.py file
- Search for “api_addr” and replace the IP address with the external ip of your Grader server.
- Search for “Welcome” and replace the Welcome message with one that is customized for your environment.
-
Edit the k8s.py file
- Search for “namespace” and modify the namespace name to the namespace of your Kubernetes environment
-
Create the Dockerfile for the Worker Pod by editing the Worker.Dockerfile
- Search for “FROM” and replace the name of the single-user Docker image you use for your course.
- Copy Worker.Dockerfile to Dockerfile
cp -v Worker.Dockerfile Dockerfile
-
Pull the single-user image you use for your environment (Example below)
sudo docker pull eespinosa/pstat134
-
Build the image for the Worker ensure the name of the new image is different than the name of the image use used in the above step (Example below)
sudo docker build --no-cache -t eespinosa/pstat134-worker:v0.5 .
-
Push the image that you just created to the docker hub. (Example below)
sudo docker push eespinosa/pstat134-worker:v0.5
-
Install the gcloud sdk and kubectl
- Use the steps on the following page
https://cloud.google.com/sdk/install
- Use the steps on the following page
-
Configure kubectl command line access by running the following command"
gcloud container clusters get-credentials <CLUSTER_NAME> --zone <ZONE_NAME> --project <PROJECT_NAME>
-
Create Service account that will run the autograder
gcloud iam service-accounts create autograder --display-name "Autograder Service Account"
-
Verify and note the name of the new account
gcloud iam service-accounts list
-
Download the Service Account Key
gcloud iam service-accounts keys create ./<NAME_OF_FILE>.json --iam-account <ACCOUNT_CREATED_ABOVE>
-
Associate the editor role to your service account
gcloud projects add-iam-policy-binding <PROJECT ID> --role <ROLE NAME> --member serviceAccount:<EMAIL ADDRESS>
-
Activate Service Account
gcloud auth activate-service-account --project=<PROJECT_ID> --key-file=<FILENAME_CREATED_ABOVE>.json
-
Start the Autograder
bash run.sh
- Github issue will be the best place to reach for support.