Fail to set up formgrade with jupyterhub

211 views
Skip to first unread message

Xin Huang

unread,
Jun 28, 2016, 10:05:54 AM6/28/16
to Project Jupyter
Hi,

I am trying to set up jupyterhub with nbgrader these days. My jupyterhub version is 0.6.1 and nbgrader version is 0.3.0.dev0

Everything works fine except formgrade.

I start jupyterhub by root, and use nbgrader by another account called instructor.
Then I go to my course directory /home/instructor/nbgrader/courses/demo and run commands according to http://nbgrader.readthedocs.io/en/stable/configuration/jupyterhub_config.html

export CONFIGPROXY_AUTH_TOKEN='mytoken'
export JPY_API_TOKEN=$(jupyterhub token --db=sqlite:////srv/jupyterhub/jupyterhub.sqlite -f /srv/jupyterhub/jupyterhub_config.py instructor)

nbgrader formgrade

It raises exceptions as follows:

[FormgradeApp | INFO] Proxying /hub/nbgrader/demo --> http://127.0.0.1:9000
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 137, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/opt/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 91, in create_connection
raise err
File "/opt/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 81, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 559, in urlopen
body=body, headers=headers)
File "/opt/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 353, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/opt/anaconda3/lib/python3.5/http/client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "/opt/anaconda3/lib/python3.5/http/client.py", line 1128, in _send_request
self.endheaders(body)
File "/opt/anaconda3/lib/python3.5/http/client.py", line 1079, in endheaders
self._send_output(message_body)
File "/opt/anaconda3/lib/python3.5/http/client.py", line 911, in _send_output
self.send(msg)
File "/opt/anaconda3/lib/python3.5/http/client.py", line 854, in send
self.connect()
File "/opt/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 162, in connect
conn = self._new_conn()
File "/opt/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 146, in _new_conn
self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.HTTPConnection object at 0x7ff3512b9
b38>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.5/site-packages/requests/adapters.py", line 376, in send
timeout=timeout
File "/opt/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 609, in urlopen
_stacktrace=sys.exc_info()[2])
File "/opt/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/retry.py", line 273, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=8001): Max retries exceeded with url:
/api/routes/hub/nbgrader/demo (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7ff3
512b9b38>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/anaconda3/bin/nbgrader", line 9, in <module>
load_entry_point('nbgrader==0.3.0', 'console_scripts', 'nbgrader')()
File "/opt/anaconda3/lib/python3.5/site-packages/nbgrader/apps/nbgraderapp.py", line 249, in main
NbGraderApp.launch_instance()
File "/opt/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/opt/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 596, in launch_instance
app.start()
File "/opt/anaconda3/lib/python3.5/site-packages/nbgrader/apps/nbgraderapp.py", line 242, in start
super(NbGraderApp, self).start()
File "/opt/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 256, in start
self.subapp.start()
File "/opt/anaconda3/lib/python3.5/site-packages/nbgrader/apps/formgradeapp.py", line 191, in start
self.init_tornado_settings()
File "/opt/anaconda3/lib/python3.5/site-packages/nbgrader/apps/formgradeapp.py", line 150, in init_tornado_settings
parent=self)
File "/opt/anaconda3/lib/python3.5/site-packages/nbgrader/auth/hubauth.py", line 94, in __init__
'target': target
File "/opt/anaconda3/lib/python3.5/site-packages/nbgrader/auth/hubauth.py", line 247, in _proxy_request
return self._request('proxy', *args, **kwargs)
File "/opt/anaconda3/lib/python3.5/site-packages/nbgrader/auth/hubauth.py", line 259, in _request
}, data=data)
File "/opt/anaconda3/lib/python3.5/site-packages/requests/api.py", line 53, in request
return session.request(method=method, url=url, **kwargs)
File "/opt/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/opt/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/opt/anaconda3/lib/python3.5/site-packages/requests/adapters.py", line 437, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8001): Max retries exceeded with url: /api/routes/hu
b/nbgrader/demo (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7ff3512b9b38>: Fail
ed to establish a new connection: [Errno 111] Connection refused',))

I can't figure out what is wrong, could you give me a help? Thanks!

My jupyterhub_config.py:

c = get_config()

c.Authenticator.whitelist = {'instructor', 'student'}
c.Authenticator.admin_users = {'instructor'}

c.JupyterHub.port = 443

c.JupyterHub.ssl_cert = 'mycert'
c.JupyterHub.ssl_key = 'mykey'

c.JupyterHub.proxy_auth_token = 'mytoken'

My nbgrader_config.py:

c = get_config()

c.TransferApp.exchange_directory = "/srv/nbgrader/exchange"

c.NbGrader.course_id = "demo"
c.NbGrader.db_assignments = [
    dict(name="ps1")
]
c.NbGrader.db_students = [
    dict(id="student", first_name="Ming", last_name="Xiao"),
]

c.FormgradeApp.ip = "127.0.0.1"
c.FormgradeApp.port = 9000
c.FormgradeApp.authenticator_class = "nbgrader.auth.hubauth.HubAuth"

import os

c.HubAuth.graders = ["instructor"]
c.HubAuth.hub_address = "127.0.0.1"
c.HubAuth.hubapi_token = os.environ['JPY_API_TOKEN']

Jessica B. Hamrick

unread,
Jun 28, 2016, 5:05:08 PM6/28/16
to jup...@googlegroups.com
Hi Xin,

I'm not entirely sure what the issue is, but it looks like you're running JupyterHub with https, which requires a bit more configuration for formgrader. Try putting the following in your nbgrader config:

c.HubAuth.hub_base_url = "https://localhost:443"

A working example of the formgrader and JupyterHub with SSL can be found in the nbgrader tests here: https://github.com/jupyter/nbgrader/blob/master/nbgrader/tests/formgrader/manager.py#L258

This is something that should definitely be documented better, so I'll open an issue for that. Let me know if this helps!

Also, you may want to upgrade to the newly released version of nbgrader, 0.3.0, rather than using the older development version that you have.

Cheers,
Jess


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/698544a8-2655-4ba1-a69a-c578ac648a21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xin Huang

unread,
Jun 29, 2016, 9:35:06 AM6/29/16
to Project Jupyter


c.HubAuth.hub_base_url = "https://localhost:443"
c.HubAuth.hub_port = 443
c.HubAuth.hubapi_port = 8081
c.HubAuth.proxy_port = 444

into my nbgrader_config.py

and run


export CONFIGPROXY_AUTH_TOKEN='mytoken'
export JPY_API_TOKEN=$(jupyterhub token --db=sqlite:////srv/jupyterhub/jupyterhub.sqlite -f /srv/jupyterhub/jupyterhub_config.py instructor)

nbgrader formgrade

It works fine now. Thank you very much.

Holger Karl

unread,
Jul 12, 2016, 1:00:56 PM7/12/16
to Project Jupyter
Hi,

oh, yes, please - document this! This discussion saved me after two afternoons of trying to get formgrader to work :-))

Thanks

Holger

Reply all
Reply to author
Forward
0 new messages