Skip to content

Commit 8776ca7

Browse files
authored
Merge pull request #111 from lxylxy123456/master
Release 0.5.0
2 parents 7e6a84b + 611b3cc commit 8776ca7

File tree

9 files changed

+48
-169
lines changed

9 files changed

+48
-169
lines changed

README.md

Lines changed: 9 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,24 @@
11
# ngshare
22
[nbgrader](https://github.com/jupyter/nbgrader) sharing service.
33

4+
<img src="ngshare/favicon.png" width="64px" />
5+
46
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
57
[![Build Status](https://travis-ci.org/lxylxy123456/ngshare.svg?branch=master)](https://travis-ci.org/lxylxy123456/ngshare)
68
[![codecov](https://codecov.io/gh/lxylxy123456/ngshare/branch/master/graph/badge.svg)](https://codecov.io/gh/lxylxy123456/ngshare)
79
[![Documentation Status](https://readthedocs.org/projects/ngshare/badge/?version=latest)](https://ngshare.readthedocs.io/en/latest/?badge=latest)
810

9-
**This service is under development. Use this at your own risk.**
10-
11-
Click [here](#installation-and-setup) for installation instructions.
12-
13-
<img src="ngshare/favicon.png" width="64px" />
14-
1511
## What can I use it for?
1612
You can use ngshare if you
17-
* Need to run nbgrader on a distributed set up (probably using
18-
[lxylxy123456/nbgrader](https://github.com/lxylxy123456/nbgrader))
19-
* Have something similar to nbgrader that also needs an API to manage courses,
20-
homework submissions and feedbacks, etc.
21-
* Want to learn Flask, SQLAlchemy, or Tornado Web Server.
13+
* Need to run nbgrader on a distributed set up (such as Zero to JupyterHub, using DockerSpawner, etc)
14+
* Need better course management without messing with filesystem permissions and user groups
2215

2316
## Documentation
24-
The API specifications and documentation for `ngshare` are in
25-
[Read the Docs](https://ngshare.readthedocs.io/en/latest/).
26-
27-
## Installation and setup
28-
* See [/testing](/testing#testing-setup) for setting up `ngshare` and `JupyterHub` for simple testing.
29-
30-
To install `ngshare` onto your cluster with some default values, simply do:
31-
32-
`helm install ngshare helmchart/ngshare`
33-
34-
We recommend using some configurations manually. Here's a sample `config.yaml` file:
35-
```yaml
36-
deployment:
37-
resources:
38-
limits:
39-
cpu: 100m
40-
memory: 128Mi
41-
42-
ngshare:
43-
# You may omit this, but the token will be randomly generated.
44-
# It's recommended to specify an API token here.
45-
hub_api_token: ENTER_TOP_SECRET_TOKEN_HERE
46-
47-
pvc:
48-
# Amount of storage for ngshare
49-
storage: 1Gi
50-
```
51-
For a reference of all the options you can specify, check [here](/helmchart/ngshare/values.yaml).
52-
53-
After you install, you should see a message like this:
54-
```
55-
Congrats, ngshare should be installed!
56-
To get started, add the following to your JupyterHub helm chart's values:
57-
58-
hub:
59-
extraConfig:
60-
ngshare.py: |
61-
c.JupyterHub.services.append({
62-
'name': 'ngshare',
63-
'url': 'http://ngshare:8080',
64-
'api_token': 'a4IHeiHZuswZrmYbWxSGpLZs3x0pXVxa'})
65-
```
66-
You should:
67-
1. Follow the first part of the instructions, and add the `extraConfig` part into your JupyterHub's helm chart.
68-
2. Modify your singleuser image to install our fork of nbgrader, and add some configuration to your default `nbgrader_config.py` so it uses ngshare. You can add something like this to your singleuser Dockerfile:
69-
```dockerfile
70-
RUN pip install git+https://github.com/lxylxy123456/nbgrader@exchange_server && \
71-
jupyter nbextension install --symlink --sys-prefix --py nbgrader && \
72-
jupyter nbextension enable --sys-prefix --py nbgrader && \
73-
jupyter serverextension enable --sys-prefix --py nbgrader
74-
75-
COPY nbgrader_config.py /etc/jupyter/
76-
```
77-
with an accompanying `nbgrader_config.py` like this:
78-
```python
79-
from nbgrader.exchange import ngshare
80-
c = get_config()
81-
c.ExchangeFactory.exchange = ngshare.Exchange
82-
c.ExchangeFactory.fetch_assignment = ngshare.ExchangeFetchAssignment
83-
c.ExchangeFactory.fetch_feedback = ngshare.ExchangeFetchFeedback
84-
c.ExchangeFactory.release_assignment = ngshare.ExchangeReleaseAssignment
85-
c.ExchangeFactory.release_feedback = ngshare.ExchangeReleaseFeedback
86-
c.ExchangeFactory.list = ngshare.ExchangeList
87-
c.ExchangeFactory.submit = ngshare.ExchangeSubmit
88-
c.ExchangeFactory.collect = ngshare.ExchangeCollect
89-
```
90-
Afterwards, the setup should be complete.
91-
92-
## Note about users in JupyterHub and ngshare
93-
In ngshare, all users (instructors and students) are identified using their username in JupyterHub. They are authenticated using the API token inside their notebook server. Be careful when reusing usernames in JupyterHub, as users with the same name will be identified as the same. We haven't added functionality to rename or delete users in ngshare, so be sure not to delete a user and create a new one with the same name. If you do, you will have to manually edit the ngshare database to remove or rename that user.
94-
95-
## Demo
96-
If you are configuring our project correctly, you should be able to run this demo.
97-
1. Setup a clean environment using JupyterHub + nbgrader + ngshare (debug mode). You can use the [minikube testing setup](/testing#testing-setup) to do it easily.
98-
2. Login as user "user". All usernames are login-able with any passwords.
99-
3. Go to "Control Panel" at upper right corner, then Services -> ngshare
100-
4. Click on "init with test data". You should see
101-
`{"success": true, "message": "done"}`.
102-
5. Login as user "kevin".
103-
6. Create a new file with New -> Text File, name it `nbgrader_config.py` and
104-
with the following content:
105-
```
106-
c = get_config()
107-
c.CourseDirectory.course_id = "course1"
108-
```
109-
7. Go to "Control Panel", click on "Stop My Server"
110-
8. Click on "Start My Server"
111-
9. Go to "Formgrader".
112-
10. Click "Add new assignment..."
113-
11. Click on the name of the assignment you just added
114-
12. New -> Notebook -> Python 3, and edit the notebook as in normal nbgrader
115-
1. Add some code to the block
116-
2. View -> Cell Toolbar -> Create Assignment
117-
3. Select "Autograded answer"
118-
4. ...
119-
5. Save notebook
120-
13. Click "Generate" in Formgrader
121-
14. Click "Release" in Formgrader
122-
15. Login as user "lawrence" (you may want to use incognito mode).
123-
16. Go to "Assignments" tab
124-
17. Click "Fetch" for the new assignment (the one that is not "challenge")
125-
18. Do your homework.
126-
19. Click "Submit".
127-
20. Login as user "kevin".
128-
21. Click "Collect" in Formgrader.
129-
22. You should see "1" under "# Submissions". Click on this number.
130-
23. Click "Autograde"
131-
24. Click Student Name, and then the notebook name, then write some feedback and
132-
click "Next".
133-
25. Go back to "Manage Assignments"
134-
26. Click "Generate Feedback", and "Release Feedback" in order.
135-
27. Login as user "lawrence".
136-
28. Under "Assignments", click "Fetch Feedback"
137-
29. You should see "(view feedback)" on the right of the time stamp, but do not
138-
click on it.
139-
30. Go to "Files" tab and go to `<assignment name>/feedback/<timestamp>`, then
140-
you can view the html feedbacks.
141-
142-
### Youtube Video Demo
143-
http://www.youtube.com/watch?v=iiaVpKLj89c
144-
145-
[![Youtube Video Demo](http://img.youtube.com/vi/iiaVpKLj89c/0.jpg)](http://www.youtube.com/watch?v=iiaVpKLj89c)
146-
147-
## Database migrations
148-
ngshare uses [Alembic](https://alembic.sqlalchemy.org/) to manage database
149-
migrations.
150-
151-
For development, first install ngshare as a repo using
152-
`pip3 install . --user --upgrade`, then initialize the database using
153-
`python3 dbutil.py upgrade head` (the path to database is defined in
154-
`dbutil.py`, which is `sqlite:////tmp/ngshare.db` by default).
17+
The API specifications, installation guide, and documentation for `ngshare` are
18+
in [Read the Docs](https://ngshare.readthedocs.io/en/latest/).
15519

156-
After changing database structure, use `pip3 install . --user --upgrade` and
157-
then `python3 dbutil.py revision --autogenerate -m "message"` to automatically
158-
detect changes, then `python3 dbutil.py upgrade head` to upgrade database
159-
structures.
20+
## Youtube Video Demo
21+
http://www.youtube.com/watch?v=SEJCaqD7xXQ
16022

161-
Ngshare / vngshare automatically checks database upgrade each time it starts up.
162-
You are expected to have a good way to backup your database before running
163-
ngshare / vngshare in case alembic corrupts the database. If you want to stop
164-
this behavior you can use `--no-upgrade-db`. If you do this, you must manually
165-
upgrade the database when upgrading ngshare. Only use this option if you know
166-
EXACTLY what you're doing, otherwise using incompatible versions will cause
167-
things to break catastrophically.
23+
[![Youtube Video Demo](http://img.youtube.com/vi/SEJCaqD7xXQ/0.jpg)](http://www.youtube.com/watch?v=SEJCaqD7xXQ)
16824

169-
## Code formatting
170-
`black -S -l 80 ngshare`

docs/api/authentication.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Authentication
44
ngshare Authentication
55
----------------------
66

7-
This section is under construction
7+
``ngshare`` uses JupyterHub authentication tokens to authenticate the user. This is usually in the ``JUPYTERHUB_API_TOKEN`` environment variable in each user's notebook servers. ``ngshare`` will use this token to fetch the username of the current user. The username is the only information used to identify the user.
88

9-
For ``ngshare``, use JupyterHub authentication token.
9+
To send the token to ``ngshare``, use the ``Authorization: token`` header in HTTP requests to ``ngshare``.
1010

1111
GET Example
1212
^^^^^^^^^^^
@@ -33,7 +33,7 @@ POST Example
3333
vngshare Authentication
3434
-----------------------
3535

36-
For ``vngshare``, supply the username to the GET param or POST data ``user``.
36+
For ``vngshare``, there is no password authentication. The username is specified in the GET param or POST data field ``user``.
3737

3838
GET Example
3939
^^^^^^^^^^^
@@ -54,4 +54,3 @@ Post Example
5454
Content-Length: 38
5555
5656
instructors=%5B%22eric%22%5D&user=root
57-

docs/contributer_guide/decisions.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Decisions
22
=========
33

4-
This section is under construction
5-
64
Technologies Employed
75
---------------------
86

docs/contributer_guide/development.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,4 @@ We use `black <https://github.com/psf/black>`_ to format our code.
4040
Contributing
4141
------------
4242

43-
If you want to contribute to ``ngshare``, submit a pull request to `https://github.com/lxylxy123456/ngshare/ <https://github.com/lxylxy123456/ngshare/>`_.
44-
45-
This section is under construction.
46-
43+
If you want to contribute to ``ngshare``, submit a pull request to `https://github.com/lxylxy123456/ngshare/pulls <https://github.com/lxylxy123456/ngshare/pulls>`_.

docs/contributer_guide/project_structure.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ Deployment
5353

5454
Testing
5555
-------
56-
``testing/`` is for installing ``ngshare`` in a Kubernetes setup.
56+
``testing/`` contains setups used for testing ngshare, ngshare_exchange, nbgrader, and Z2JH.
5757

58-
This section is under construction
58+
``testing/docker`` contains a Docker environment for initial testing. It is slightly out of date and still uses our fork of ngshare rather than ngshare_exchange.
59+
60+
``testing/minikube`` contains a minikube environment. This is the main testing setup for local development, and it uses ngshare and ngshare_exchange on the local filesystem.
61+
62+
``testing/install_jhmanaged`` contains a Docker environment that demonstrates how a regular user would install ngshare and ngshare_exchange.
63+
64+
``testing/install_z2jh`` contains a minikube environment that demonstrates how a regular user would install ngshare and ngshare_exchange on a standard Kubernetes cluster.
65+
66+
ngshare_exchange
67+
----------------
68+
The client side of ngshare is packaged into a `separate repo <https://github.com/lxylxy123456/ngshare_exchange>`_.
69+
70+
``ngshare_exchange/*.py`` implement a nbgrader pluggable exchange that uses ngshare to release, fetch, and submit assignments.
71+
72+
``ngshare_exchange/course_management.py`` will be installed as the ``ngshare-course-management`` command. It is used for admins and instructors to manage course rosters.

docs/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ ngshare
2323

2424
To solve this problem, we are letting exchange to gather all information it needs from a set of REST APIs, which is implemented by ``ngshare``.
2525

26+
Youtube Video Demo
27+
------------------
28+
29+
.. raw:: html
30+
31+
<p><iframe width="640" height="360" src="https://www.youtube.com/embed/SEJCaqD7xXQ" frameborder="0" allowfullscreen></iframe></p>
32+
2633
Table of Contents
2734
-----------------
2835

docs/user_guide/install_z2jh.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Installing on a Z2JH Cluster
22
============================
33

4-
This guide assumes you are already familiar with installing Z2JH. You should also be familiar with using Helm.
4+
This guide assumes you already have a Kubernetes cluster with a persistent volume provisioner (which should be the case if you run Z2JH). You should also be familiar with installing Z2JH and using Helm.
55

66
If you prefer looking at examples instead, `here's <https://github.com/lxylxy123456/ngshare/tree/master/testing/install_z2jh>`_ a sample installation setup. It doesn't demonstrate all the configurable options, though.
77

docs/user_guide/notes_admin.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,20 @@ Admin Users
66
-----------
77
Admin users are the only users who can create courses and assign instructors to them. This is to prevent unauthorized users from creating courses. All admins have full access to every course on ``ngshare``, so keep this in mind when assigning admins. Courses can be created and managed using the `ngshare-course-management <course_management.html>`_ tool that comes with ``ngshare_exchange``.
88

9+
User Name Reuse
10+
---------------
11+
In ngshare, all users (instructors and students) are identified using their username in JupyterHub. They are authenticated using the API token inside their notebook server. Be careful when reusing usernames in JupyterHub, as users with the same name will be identified as the same. We haven't added functionality to rename or delete users in ngshare, so be sure not to delete a user and create a new one with the same name. If you do, you will have to manually edit the ngshare database to remove or rename that user.
12+
913
Race Condition
1014
--------------
1115
ngshare should NOT be run concurrently, or there may be race conditions and data may be corrupted. For example, do not create multiple ngshare instances that share the same underlying database.
1216

17+
Storage
18+
-------
19+
If you're using the Helm chart, only 1GiB of storage is allocated by default. You may increase this limit by specifying `pvc.storage` in the Helm values. If ngshare returns 500 for requests, lack of storage space could be a reason.
20+
21+
Also, when courses or assignments are deleted, their corresponding files are not automatically deleted. You may want to delete these files to clean up storage. See the Removing Semantics section below for more info.
22+
1323
Database Upgrade
1424
----------------
1525
ngshare checks the database version every time it starts up. If the database version is older than the ngshare version, it performs schema and data migration.

ngshare/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.4.0'
1+
__version__ = '0.5.0'

0 commit comments

Comments
 (0)