Skip to content
Snippets Groups Projects

WIP: Add new submission class which will communicate with the RWTH JupyterHub service

Merged Steffen Vogel requested to merge submission into master

Files

+ 97
0
%% Cell type:markdown id: tags:
# Example notebooks for using the submission service
%% Cell type:code id: tags:
``` python
from rwth_nb.misc.submission import Submission
from random import randint
from pprint import pprint
sub = Submission('test_realm')
```
%% Cell type:code id: tags:
``` python
print('\nCreate some random submissions...')
for i in range(5):
sub.submit({
'random_integer': randint(1, 100)
})
```
%% Cell type:markdown id: tags:
## Admin actions
For performing admin actions the user must own the role manager-{profile_slug} or submission-{realm}
%% Cell type:code id: tags:
``` python
print('\nAll submissions:')
pprint(sub.get_all())
print('\nDelete all submissions')
sub.delete_all()
print('\nAll submissions:')
pprint(sub.get_all())
```
%% Cell type:markdown id: tags:
## User actions
%% Cell type:code id: tags:
``` python
if sub.is_submitted():
print('\nEvaluation already submitted')
else:
print('\nNothing submitted yet!')
sub.submit({'test': [1, 2, 3]})
if sub.is_submitted():
print('\nNow it is submitted!:')
pprint(sub.get())
print('\nMy submissions:')
mysubs = sub.get()
print(mysubs)
ident = mysubs[0]['id']
print(f'\nMy submission ID: {ident}')
print(f'\nDeleting my submission with ID: {ident}')
sub.delete(ident=ident)
print('\nMy submissions:')
mysubs = sub.get()
print(mysubs)
```
%% Cell type:markdown id: tags:
## Submitting whole notebooks
The following cell submits the current notebook contents
%% Cell type:code id: tags:
``` python
sub.submit_notebook()
```
%% Cell type:markdown id: tags:
The following cell fetches all submitted notebooks in the current realm by the current user and stores them in the current directory
%% Cell type:code id: tags:
``` python
sub.fetch_notebook(subdir='fetched_notebooks', prefix='a1')
```
Loading