|
1 | 1 | # ngshare
|
2 | 2 | [nbgrader](https://github.com/jupyter/nbgrader) sharing service.
|
3 | 3 |
|
| 4 | +<img src="ngshare/favicon.png" width="64px" /> |
| 5 | + |
4 | 6 | [](https://github.com/psf/black)
|
5 | 7 | [](https://travis-ci.org/lxylxy123456/ngshare)
|
6 | 8 | [](https://codecov.io/gh/lxylxy123456/ngshare)
|
7 | 9 | [](https://ngshare.readthedocs.io/en/latest/?badge=latest)
|
8 | 10 |
|
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 |
| - |
15 | 11 | ## What can I use it for?
|
16 | 12 | 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 |
22 | 15 |
|
23 | 16 | ## 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 |
| -[](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/). |
155 | 19 |
|
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 |
160 | 22 |
|
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 | +[](http://www.youtube.com/watch?v=SEJCaqD7xXQ) |
168 | 24 |
|
169 |
| -## Code formatting |
170 |
| -`black -S -l 80 ngshare` |
0 commit comments