Skip to content

Commit

Permalink
Add course repo + refactor + fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sverhoeven committed Feb 14, 2024
1 parent ab489be commit 648ad57
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 74 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ dcache_ro_token: <dcache macaroon with read permission>
rclone_cache_dir: /data/volume_2
# Directory where /home should point to
alt_home_location: /data/volume_3
# Vagrant user is instructor
# The students defined below can be used to login as a student
students: '[["student1", "student1"], ["student2", "student2"]]'
```
The token can be found in the eWaterCycle password manager.
Expand Down Expand Up @@ -104,6 +107,15 @@ For eWatercycle component following specialization was done
For directory where rclone can store its cache.
- Add `rclone_max_gsize` with value `45`.
For maximum size of cache on `rclone_cache_dir` volume. In Gb.
- Add `grader_user` parameter with username of person who will be grading.
Use `==USERNAME==` as default value, which will be replaced by the actual username of the user creating the workspace.
This user will also be responsible for setting up the course and assignments.
- Add `students` parameter with list of student usernames and passwords.
The value should be a JSON string in format of `[["username1", "password1"]]`.
- Add `course_repo` parameter with git repository url of the course source material.
Use default value of `https://github.com/eWaterCycle/teaching.git`
- Add `course_version` paramneter with the version,branch or tag of the course repository to use.
Default value of `main`.
- Set documentation URL to `https://github.com/eWaterCycle/infra`
- Do not allow every org to use this component. Data on the dcache should not be made public.
- Select the organizations (CO) that are allowed to use the component.
Expand All @@ -123,6 +135,7 @@ For eWatercycle catalog item following specialization was done
- In parameter settings step keep all values as is except
- Set `co_irods` to `false` as we do not use irods
- Set `co_research_drive` to `false` as we do not use research drive
- Expose `grader_user`, `students`, `course_repo` and `course_version` as interactive parameters.
- Set boot disk size to 150Gb,
as default size will be mostly used by the conda environment and will trigger out of space warnings.
- Set workspace acces button behavior to `Webinterface (https:)`,
Expand Down
16 changes: 1 addition & 15 deletions TEACH.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@

The grading setup is [one class, one grader](https://nbgrader.readthedocs.io/en/stable/configuration/jupyterhub_config.html#example-use-case-one-class-one-grader).

## Surf Research Cloud configuration

In the SRC component

- Add `grader_user` parameter with username of person who will be grading.
Use `==USERNAME==` as default value, which will be replaced by the actual username of the user creating the workspace.
This user will also be responsible for setting up the course and assignments.
- Add `students` parameter with list of student usernames and passwords.
The value should be a JSON string in format of `[["username1", "password1"]]`.

In the SRC catalog item

- Expose `grader_user` and `student_users` as interactive parameters.

## SRC workspace creation

During creation you can set the `students` parameter to create local posix accounts for students.
Expand All @@ -32,7 +18,7 @@ After sram invite a cronjob will add the user to the VM. Login with totp as pass
## Create assignment

1. In menu goto Nbgrader -> Formgrader -> Manage Assignments -> Add new Assignment.
2. Click on edit to navigate to folder (`~/hydrolog101/source/<name of assignment>`).
2. Click on edit to navigate to folder (`~/course/source/<name of assignment>`).
3. Create a notebook with assignment annotations using the `Create Assignment` sidebar.
4. In FormGrader press Generate, Preview, Release buttons.

Expand Down
9 changes: 8 additions & 1 deletion roles/grader/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
# defaults file for grader
exchange_root: /var/local/nbgrader/exchange
grader_user: vagrant
course_id: hydrolog101
course_id: course1
course_repo: https://github.com/eWaterCycle/teaching.git
course_version: nbgrader-quickstart
conda_root: /opt/conda
# Name of conda environment to use
conda_environment: ewatercycle2
# Path to conda environments bin directory
conda_environment_bin: '{{ conda_root }}/envs/{{ conda_environment }}/bin'
58 changes: 10 additions & 48 deletions roles/grader/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,14 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker

# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)

min_ansible_version: 2.1

# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:

#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99

author: Stefan Verhoeven
description: nbgrader
company: Netherlands eScience Center
license: Apache-2.0

min_ansible_version: '2.4'
platforms:
- name: Ubuntu
versions:
- all
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
37 changes: 27 additions & 10 deletions roles/grader/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,65 @@
---
# tasks file for grader
- name: Exchange directory
file:
ansible.builtin.file:
path: '{{ exchange_root }}'
state: directory
mode: '0777'
mode: '0777'
- name: /etc/jupyter
file:
ansible.builtin.file:
path: /etc/jupyter
state: directory
mode: '0755'
- name: Global nbgrader config
copy:
ansible.builtin.copy:
dest: /etc/jupyter/nbgrader_config.py
mode: 0644
content: |
c = get_config()
c.Exchange.root = '{{ exchange_root }}'
- name: Grader jupyter dir
file:
ansible.builtin.file:
path: /home/{{ grader_user }}/.jupyter
state: directory
owner: '{{ grader_user }}'
group: '{{ grader_user }}'
mode: '0755'

- name: nbgrader config for grader user
copy:
- name: Nbgrader config for grader user
ansible.builtin.copy:
dest: /home/{{ grader_user }}/.jupyter/nbgrader_config.py
mode: 0644
owner: '{{ grader_user }}'
group: '{{ grader_user }}'
content: |
c = get_config()
c.CourseDirectory.course_id = '{{ course_id }}'
c.CourseDirectory.root = '/home/{{ grader_user }}/{{ course_id }}'
- name: Course directory
file:
ansible.builtin.file:
path: '/home/{{ grader_user }}/{{ course_id }}'
state: directory
owner: '{{ grader_user }}'
group: '{{ grader_user }}'
mode: '0755'
- name: Clone course repo
ansible.builtin.git:
repo: '{{ course_repo }}'
dest: '/home/{{ grader_user }}/{{ course_id }}/source'
version: '{{ course_version }}'
become: true
become_user: "{{ grader_user }}"
- name: Create students
when: students is defined
user:
ansible.builtin.user:
name: "{{ item[0] }}"
password: "{{ item[1] | password_hash(hashtype='sha512') }}"
shell: /bin/bash
loop: "{{ students | from_json }}"
- name: Add students to course
when: students is defined
ansible.builtin.command: '{{ conda_environment_bin }}/nbgrader db student add "{{ item[0] }}"'
loop: "{{ students | from_json }}"
args:
chdir: "/home/{{ grader_user }}/{{ course_id }}"
become: true
become_user: "{{ grader_user }}"

0 comments on commit 648ad57

Please sign in to comment.