Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup nbgrader in one class, one grader mode #155

Open
wants to merge 73 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
377783d
Setup nbgrader in one class, one grader mode
sverhoeven Feb 13, 2024
605ff3a
Add student creation via interacve src parameter + try e2xgrader
sverhoeven Feb 13, 2024
77a8cd2
Drop e2xgrader is not a lab extension yet, removing it
sverhoeven Feb 13, 2024
214f652
Improve docs
sverhoeven Feb 13, 2024
aa9c7ef
Add sudo
sverhoeven Feb 13, 2024
52368c7
No longer need experimental env var with latest vagrant
sverhoeven Feb 14, 2024
c55b2fe
Fix license
sverhoeven Feb 14, 2024
ab489be
Fix ERROR: Failed to find specified config file: /etc/jupyterhub/jupy…
sverhoeven Feb 14, 2024
648ad57
Add course repo + refactor + fix lint errors
sverhoeven Feb 14, 2024
6d1b87d
Dont use deprecated include
sverhoeven Feb 14, 2024
1195457
nbgrader does subprocess alembic, but was not in path so activate con…
sverhoeven Feb 14, 2024
ee6ab9a
Set PATH env var so alembic can be found
sverhoeven Feb 14, 2024
37e6ab5
Update TEACH.md
sverhoeven Feb 14, 2024
1d35fb2
Test out named volumes + cluster
sverhoeven Feb 28, 2024
5b78a67
Merge branch 'grader' of github.com:eWaterCycle/infra into grader
sverhoeven Feb 28, 2024
178632d
Mirror rs dat more
sverhoeven Feb 28, 2024
eb66ff2
Expose worker_ip_addresses as plugin resource parameter
sverhoeven Feb 28, 2024
326a8a2
unneeded if
sverhoeven Feb 28, 2024
58a91ac
Skip cluster
sverhoeven Feb 28, 2024
01a0a8c
Really skip cluster, left is named storage
sverhoeven Feb 28, 2024
1938143
Expose attached storage items as interactive parameters
sverhoeven Feb 28, 2024
dbec610
re-enable all roles
sverhoeven Feb 28, 2024
dc5df4e
Better docs
sverhoeven Feb 28, 2024
5575997
Merge TEACH.md into other docs
sverhoeven Feb 28, 2024
ce4c108
Pick right branch
sverhoeven Feb 28, 2024
fbe8706
Add all non grader non system users as students + disable some nbgrad…
sverhoeven Feb 28, 2024
ac455f0
Dump worker_ip_addresses
sverhoeven Feb 28, 2024
1e50645
false is not a command
sverhoeven Feb 28, 2024
1534fec
List users in /home
sverhoeven Feb 28, 2024
012f1ac
More todos
sverhoeven Feb 28, 2024
ed39428
Debug students parameter
sverhoeven Mar 6, 2024
3bb530f
Sync README with live src config
sverhoeven Mar 6, 2024
d5a91c2
Disable explore & launcher, not needed for teaching
sverhoeven Mar 6, 2024
3870712
Try to fix list users + use nbgrader demo commands
sverhoeven Mar 6, 2024
29b5ba0
Add screenshot of parameters.
sverhoeven Mar 6, 2024
04c981d
Just show jupyter card on home page
sverhoeven Mar 6, 2024
f588496
For non_grader_users use same command as myusers + disable unwanted e…
sverhoeven Mar 6, 2024
1ce7c2a
Make even more similar
sverhoeven Mar 6, 2024
7c67bb6
Install bleeding edge nbgrader for working validate button
sverhoeven Mar 6, 2024
e8383d8
Fallback to legacy shell module
sverhoeven Mar 6, 2024
d97fa71
Use legacy command and use module parameter
sverhoeven Mar 6, 2024
7d8d938
Debug ansible version
sverhoeven Mar 6, 2024
63b4f2c
Remove debug
sverhoeven Mar 6, 2024
063ef96
The double qoutes in students json string are being swllowed by SRC.
sverhoeven Mar 14, 2024
daa27ca
Dont use json for students list
sverhoeven Mar 14, 2024
97ec9da
Do splits of students in loop and task
sverhoeven Mar 20, 2024
f1c9db1
Drop ==USERNAME== as default in catalog item
sverhoeven Mar 20, 2024
06a5f87
Call split on string
sverhoeven Mar 20, 2024
8d30bbb
Rewrite plugin for src cluster support
sverhoeven Mar 20, 2024
fdbb0f4
Empty string is treated as ['']
sverhoeven Mar 20, 2024
5b484fa
Add nfs server
sverhoeven Mar 20, 2024
151297c
Correct yaml
sverhoeven Mar 20, 2024
5381683
Dont do tasks with worker_ip_addresses when its undefined
sverhoeven Mar 21, 2024
019f029
less warnings
sverhoeven Mar 21, 2024
0ddd8a8
Use is defined
sverhoeven Mar 21, 2024
3fd8dce
Clean apt cache after last install not before
sverhoeven Mar 21, 2024
3ca61cf
only fill known hosts when there are workers
sverhoeven Mar 21, 2024
a9de677
Correct indentation
sverhoeven Mar 21, 2024
f5fac91
Fix some lint warnings
sverhoeven Mar 21, 2024
3d55855
Log versions
sverhoeven Mar 21, 2024
bf84eee
Comment out cluster stuff, too many tries bringing it up
sverhoeven Mar 21, 2024
cae24a3
Bump ewatercycle version to 2.1
BSchilperoort Mar 26, 2024
142dc94
Set Content-Security-Policy "frame-ancestors header
sverhoeven Apr 10, 2024
4e9f6f6
Format
sverhoeven Apr 10, 2024
e1b6403
Get current users with home from /etc/passwd
sverhoeven Apr 10, 2024
2183cf7
Just self
sverhoeven Apr 10, 2024
b426db2
Allow logins on JupyterHub 5.0
sverhoeven Jun 27, 2024
8b15bab
Update main.yml
sverhoeven Jul 8, 2024
4fb1e13
Merge remote-tracking branch 'origin/main' into grader
sverhoeven Sep 5, 2024
8029fbc
Make index.html simpler
sverhoeven Sep 5, 2024
aa4090e
Use /jupyter/hub from variable
sverhoeven Sep 5, 2024
5d2cc1c
Use right key
sverhoeven Sep 5, 2024
609c3c6
add back vagrant virtualbox wsl2 plugin
sverhoeven Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 80 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

This repo contains (codified) instructions for deploying the eWaterCycle platform. The target audience of these instructions are system administrators. For more information on the eWaterCycle platform (and how to deploy it) see the [eWaterCycle documentation](https://ewatercycle.readthedocs.io/).

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

For instructions on how to use the machine as deployed by this repo see the [User guide](USER.md).

These instructions assume you have some basic knowledge of [vagrant](https://vagrantup.com) and
Expand All @@ -14,7 +16,7 @@ These instructions assume you have some basic knowledge of [vagrant](https://vag

The hardware environment used by the eWaterCycle platform development team is the [SURF Research Cloud](https://servicedesk.surfsara.nl/wiki/display/WIKI/Research+Cloud+Documentation). Starting a machine on the Surf Research Cloud requires that you have research budget with SURF, for more info see the website of [SURF](https://www.surf.nl/en/research-it/apply-for-access-to-compute-services). Once running, access to the machine can be shared to anyone.

The setup instructions in this repo will create an eWaterCycle application(a sort-of VM template) that when started will create a machine with:
The setup instructions in this repo will create an eWaterCycle application(a sort-of VM template) that when started will create a machine with:****

- Explorer: web visualization of available models / parameter sets combinations and a way to generate Jupyter notebooks
- Jupyter Hub: to interactivly generate forcings and perform experiments on hydrological models using the [eWatercycle Python package](https://ewatercycle.readthedocs.io/)
Expand Down Expand Up @@ -47,15 +49,17 @@ 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:pw1,student2:pw2'
worker_ip_addresses: []
```

The token can be found in the eWaterCycle password manager.

```shell
vagrant --version
# Vagrant 2.4.1
vagrant plugin install vagrant-vbguest
# Installed the plugin 'vagrant-vbguest (0.32.0)'
vagrant up
```

Expand All @@ -78,6 +82,7 @@ Importantly:

- Work on a folder on the windows file system.
- Export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/.../infra"
- Install vagrant plugin https://github.com/Karandash8/virtualbox_WSL2
- `export PATH="$PATH:C:\Program Files\Oracle\VirtualBox"`
- ` vagrant up --provider virtualbox`
- Approve the firewall popup
Expand All @@ -94,17 +99,41 @@ For eWatercycle component following specialization was done
- Use Ansible playbook as component script type
- Use `https://github.com/eWaterCycle/infra.git` as repository URL
- Use `research-cloud-plugin.yml` as script path
- Use `main` as tag
- Component parameters, all fixed source type and non-overwitable unless otherwise stated
- Add `dcache_ro_token` parameter for dcache read-only token aka macaroon.
The token can be found in the eWaterCycle password manager.
This token has an expiration date, so it needs to be updated every now and then.
- Add `alt_home_location` parameter with value `/data/volume_2`.
For mount point of the storage item which should hold homes mounted.
- Add `rclone_cache_dir` parameter with value `/data/volume_3`.
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.
- Use `grader` as tag
- Select cloud providers:
- SURF HPC Cloud, with all non-gpu sizes selected
- SURF HPC Cloud cluster, with all non-gpu sizes selected
- Component parameters, all fixed source type, required and overwitable unless otherwise stated
- dcache_ro_token: parameter for dcache read-only token aka macaroon.
The token can be found in the eWaterCycle password manager.
This token has an expiration date, so it needs to be updated every now and then.
- description: Macaroon with read permission for dcache
- alt_home_location:
- default: /data/volume_2
- description: Path where home directories are stored. Set to `/data/<storage item name for homes>`.
- rclone_cache_dir:
- default: /data/volume_3
- description: Path where rclone cache is stored. Set to `/data/<storage item name for rclone cache>`.
- rclone_max_gsize:
- default: 45
- description: For maximum size of cache on `rclone_cache_dir` volume. In Gb.
- grader_user:
- description: User who will be grading. User should be created on sram. This user will also be responsible for setting up the course and assignments.
- default: ==USERNAME==
(==USERNAME== which will be replaced by the actual username of the user creating the workspace)
- students:
- default: []
- description: List of student user name and passwords. Format '<username1>:<password1>,<username2>:<password2>'. Use '' for no students. Use secure passwords as anyone on the internet can access the machine.
- course_repo:
- default: https://github.com/eWaterCycle/teaching.git
- description: Git repository url with the course source material.
- course_version
- description: The version, branch or tag of the course repository to use.
- default: nbgrader-quickstart
- worker_ip_addresses:
- source type: Resource
- default: worker_ip_addresses
- desciption: Makes addresses of workers available to Ansible playbook. Only used when cloud provider `SURF HPC Cloud cluster` is selected.
- 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 @@ -118,17 +147,39 @@ For eWatercycle catalog item following specialization was done
4. SRC-External plugin
5. eWatercycle
- Set documentation URL to `https://github.com/eWaterCycle/infra`
- Add `SURF HPC Cloud` as cloud provider
- Set Operating Systems to Ubuntu 22.04
- Set Sizes to all non-gpu and non-disabled sizes
- Select the organizations (CO) that are allowed to use the catalog item.
- In cloud provider and settings step:
- Add `SURF HPC Cloud` as cloud provider
- Set Operating Systems to Ubuntu 22.04
- Set Sizes to all non-gpu and non-disabled sizes
- Add `SURF HPC Cloud cluster` as cloud provider
- Set Operating Systems to Ubuntu 22.04
- Set Sizes to all non-gpu and non-disabled sizes
- 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
- As interactive parameters expose following:
- rclone_cache_dir:
- label: Rclone cache directory
- description: Path where rclone cache is stored. Set to `/data/<storage item name for rclone cache>`.
- alt_home_location:
- label: Homes path
- description: Path where home directories are stored. Set to `/data/<storage item name for homes>`.
- grader_user:
- label: Username of grader
- description: User who will be grading. User should be created on sram.
- default: empty string
- students
- label: Students
- description: List of student user name and passwords. Format '<username1>:<password1>,<username2>:<password2>'. Use '' for no students. Use secure passwords as anyone on the internet can access the machine.
- num_nodes
- label: Number of nodes
- description: Only used when cloud provider `SURF HPC Cloud cluster` is selected.
- default: 2
- 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:)`,
so clicking on `ACCESS` button will open up the eWatercycle experiment explorer web interface
- Select the organizations (CO) that are allowed to use the catalog item.

To become root on a VM the user needs to be member of the `src_co_admin` group on [SRAM](https://sram.surf.nl/).
See [docs](https://servicedesk.surf.nl/wiki/display/WIKI/Workspace+roles%3A+Appoint+a+CO-member+a+SRC+administrator).
Expand All @@ -150,12 +201,12 @@ This chapter is dedicated for application deployers.
1. Select eWaterCycle application
1. Select collaborative organisation (CO) for example `ewatercycle-nlesc`
1. Select size of VM (cpus/memory) based on use case
1. Select home storage item.
- Order in which the storage items are select is important, make sure to select home before cache storage item.
1. Select cache storage item
1. Wait for machine to be running
1. Visit URL/IP
1. When done delete machine
1. Select home storage item and cache storage item. Remember items you picked as you will need them in the workspace parameters.
1. Fill **all** the workspace parameters. They should look something like
![workspace-parameters](workspace-parameters.png)
2. Wait for machine to be running
3. Visit URL/IP
4. When done delete machine

For a new CO make sure

Expand All @@ -166,6 +217,11 @@ End user should be invited to CO so they can login.

See [User guide](USER.md) to see what users have to do to login or use GitHub repository.

### Students

During creation you can set the `students` parameter to create local posix accounts for students.
The value for the `students` parameter is a list of [student, password] values. You can use the python script [create_student_passwords.py](create_student_passwords.py) to generate passwords. To use it, create a file "usernames.txt" with one username on each line. Then call the script to generate passwords. They will be stored in a new file called `students.txt`. See docs in script for more details. The passwords generated by the script should be distributed to the students.

### Example notebooks

To get example notebooks end users should use following URL (with `<workspace id>` with your currently running workspace)
Expand Down
46 changes: 40 additions & 6 deletions USER.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# User guide

- [User guide](#user-guide)
- [Grading](#grading)
- [Students](#students)
- [Create assignment](#create-assignment)
- [Fetch assignment](#fetch-assignment)
- [Logging into server](#logging-into-server)
- [Save notebooks to GitHub](#save-notebooks-to-github)
- [1. Create GitHub account](#1-create-github-account)
- [2. Create GitHub repository](#2-create-github-repository)
- [3. Setup GitHub authentication on server](#3-setup-github-authentication-on-server)
- [4. Clone repository](#4-clone-repository)
- [5. Add \& commit \& push notebooks on server to GitHub](#5-add--commit--push-notebooks-on-server-to-github)
- [6. Pull changes from GitHub to server](#6-pull-changes-from-github-to-server)
- [Install own software](#install-own-software)

## Grading

One user is the grader on the machine following section is for that user.

### Students

Assigning students to courses can be managed with [nbgrader labextension & cli](https://nbgrader.readthedocs.io/en/stable/user_guide/managing_the_database.html#managing-students).

The student id is a posix username in the VM.
In a ewatercycle VM, users can be added during workspace creation or with [Surf Research Access Management](https://sram.surf.nl/) or later with `sudo adduser`.
After sram invite a cronjob will add the user to the VM. Login with totp as password.
Users added to sram need to be added to nbgrader manually.

### Create assignment

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

### Fetch assignment

1. In menu got Nbgrader -> Assignments
2. Press fetch button

## Logging into server

You should have recieved a invitation to a eWatercycle collaborative organization, please follow instructions in email.
Expand All @@ -14,12 +54,6 @@ The username you should use to login can be found on on [SRC dashboard profile p
The Jupyter notebooks that you write should be saved outside the Jupyter server.
Code like notebooks can be saved git repositories on [GitHub](https://github.com/).

- [1. Create GitHub account](#1-create-github-account)
- [2. Create GitHub repository](#2-create-github-repository)
- [3. Setup authenication on server](#3-setup-authenication-on-server)
- [4. Clone repository](#4-clone-repository)
- [5. Add & commit & push notebooks on server to GitHub](#5-add--commit--push-notebooks-on-server-to-github)
- [6. Pull changes from GitHub to server](#6-pull-changes-from-github-to-server)

### 1. Create GitHub account

Expand Down
4 changes: 4 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Vagrant.configure("2") do |config|
config.vm.disk :disk, size: "20GB", name: "home2"
config.vm.disk :disk, size: "50GB", name: "cache"

# Disable guest updates
config.vbguest.auto_update = false
config.vbguest.no_install = true

config.vm.provision "ansible_local" do |ansible|
ansible.playbook = "vagrant-provision.yml"
ansible.become = true
Expand Down
32 changes: 32 additions & 0 deletions create_student_passwords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Script to generate passwords for users.

```shell
cat usernames.txt
user1
user2
```

```
python3 create_student_passwords.py < usernames.txt > students.txt
```

"""

from secrets import token_urlsafe

password_length = 32

def main():
usernames = []
while True:
try:
line = input()
if not line:
break
usernames.append(line.strip())
except EOFError:
break
userpws = [':'.join([username, token_urlsafe(password_length)]) for username in usernames]
print(','.join(userpws))

main()
Loading
Loading