mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-08 02:24:08 +00:00
s/JupyterHubApp/JupyterHub/
users shouldn't need to know wtf Applications are
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
c = get_config()
|
c = get_config()
|
||||||
|
|
||||||
# Add some users.
|
# Add some users.
|
||||||
c.JupyterHubApp.admin_users = {'rhea'}
|
c.JupyterHub.admin_users = {'rhea'}
|
||||||
c.Authenticator.whitelist = {'ganymede', 'io', 'rhea'}
|
c.Authenticator.whitelist = {'ganymede', 'io', 'rhea'}
|
||||||
|
|
||||||
# These environment variables are automatically supplied by the linked postgres
|
# These environment variables are automatically supplied by the linked postgres
|
||||||
@@ -11,7 +11,7 @@ c.Authenticator.whitelist = {'ganymede', 'io', 'rhea'}
|
|||||||
import os;
|
import os;
|
||||||
pg_pass = os.getenv('POSTGRES_ENV_JPY_PSQL_PASSWORD')
|
pg_pass = os.getenv('POSTGRES_ENV_JPY_PSQL_PASSWORD')
|
||||||
pg_host = os.getenv('POSTGRES_PORT_5432_TCP_ADDR')
|
pg_host = os.getenv('POSTGRES_PORT_5432_TCP_ADDR')
|
||||||
c.JupyterHubApp.db_url = 'postgresql://jupyterhub:{}@{}:5432/jupyterhub'.format(
|
c.JupyterHub.db_url = 'postgresql://jupyterhub:{}@{}:5432/jupyterhub'.format(
|
||||||
pg_pass,
|
pg_pass,
|
||||||
pg_host,
|
pg_host,
|
||||||
)
|
)
|
||||||
|
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
c = get_config()
|
c = get_config()
|
||||||
|
|
||||||
c.JupyterHubApp.admin_users = {'rhea'}
|
c.JupyterHub.admin_users = {'rhea'}
|
||||||
c.LocalProcessSpawner.set_user = 'sudo'
|
c.LocalProcessSpawner.set_user = 'sudo'
|
||||||
c.Authenticator.whitelist = {'ganymede', 'io', 'rhea'}
|
c.Authenticator.whitelist = {'ganymede', 'io', 'rhea'}
|
||||||
|
@@ -55,32 +55,31 @@ from .spawner import Spawner, LocalProcessSpawner
|
|||||||
|
|
||||||
aliases = {
|
aliases = {
|
||||||
'log-level': 'Application.log_level',
|
'log-level': 'Application.log_level',
|
||||||
'f': 'JupyterHubApp.config_file',
|
'f': 'JupyterHub.config_file',
|
||||||
'base-url': 'JupyterHubApp.base_url',
|
'base-url': 'JupyterHub.base_url',
|
||||||
'config': 'JupyterHubApp.config_file',
|
'config': 'JupyterHub.config_file',
|
||||||
'y': 'JupyterHubApp.answer_yes',
|
'y': 'JupyterHub.answer_yes',
|
||||||
'ssl-key': 'JupyterHubApp.ssl_key',
|
'ssl-key': 'JupyterHub.ssl_key',
|
||||||
'ssl-cert': 'JupyterHubApp.ssl_cert',
|
'ssl-cert': 'JupyterHub.ssl_cert',
|
||||||
'ip': 'JupyterHubApp.ip',
|
'ip': 'JupyterHub.ip',
|
||||||
'port': 'JupyterHubApp.port',
|
'port': 'JupyterHub.port',
|
||||||
'db': 'JupyterHubApp.db_url',
|
'db': 'JupyterHub.db_url',
|
||||||
'pid-file': 'JupyterHubApp.pid_file',
|
'pid-file': 'JupyterHub.pid_file',
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = {
|
flags = {
|
||||||
'debug': ({'Application' : {'log_level': logging.DEBUG}},
|
'debug': ({'Application' : {'log_level': logging.DEBUG}},
|
||||||
"set log level to logging.DEBUG (maximize logging output)"),
|
"set log level to logging.DEBUG (maximize logging output)"),
|
||||||
'generate-config': ({'JupyterHubApp': {'generate_config': True}},
|
'generate-config': ({'JupyterHub': {'generate_config': True}},
|
||||||
"generate default config file"),
|
"generate default config file"),
|
||||||
'no-db': ({'JupyterHubApp': {'db_url': 'sqlite:///:memory:'}},
|
'no-db': ({'JupyterHub': {'db_url': 'sqlite:///:memory:'}},
|
||||||
"disable persisting state database to disk"
|
"disable persisting state database to disk"
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
SECRET_BYTES = 2048 # the number of bytes to use when generating new secrets
|
SECRET_BYTES = 2048 # the number of bytes to use when generating new secrets
|
||||||
|
|
||||||
|
class JupyterHub(Application):
|
||||||
class JupyterHubApp(Application):
|
|
||||||
"""An Application for starting a Multi-User Jupyter Notebook server."""
|
"""An Application for starting a Multi-User Jupyter Notebook server."""
|
||||||
name = 'jupyterhub'
|
name = 'jupyterhub'
|
||||||
|
|
||||||
@@ -182,7 +181,7 @@ class JupyterHubApp(Application):
|
|||||||
self.log.warn('\n'.join([
|
self.log.warn('\n'.join([
|
||||||
"",
|
"",
|
||||||
"Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require restarting the proxy.",
|
"Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require restarting the proxy.",
|
||||||
"Set CONFIGPROXY_AUTH_TOKEN env or JupyterHubApp.proxy_auth_token config to avoid this message.",
|
"Set CONFIGPROXY_AUTH_TOKEN env or JupyterHub.proxy_auth_token config to avoid this message.",
|
||||||
"",
|
"",
|
||||||
]))
|
]))
|
||||||
token = orm.new_token()
|
token = orm.new_token()
|
||||||
@@ -688,11 +687,17 @@ class JupyterHubApp(Application):
|
|||||||
|
|
||||||
@catch_config_error
|
@catch_config_error
|
||||||
def initialize(self, *args, **kwargs):
|
def initialize(self, *args, **kwargs):
|
||||||
super(JupyterHubApp, self).initialize(*args, **kwargs)
|
super().initialize(*args, **kwargs)
|
||||||
if self.generate_config:
|
if self.generate_config:
|
||||||
return
|
return
|
||||||
self.load_config_file(self.config_file)
|
self.load_config_file(self.config_file)
|
||||||
self.init_logging()
|
self.init_logging()
|
||||||
|
if 'JupyterHubApp' in self.config:
|
||||||
|
self.log.warn("Use JupyterHub in config, not JupyterHubApp. Ignoring config:\n%s",
|
||||||
|
'\n'.join('JupyterHubApp.{key} = {value!r}'.format(key=key, value=value)
|
||||||
|
for key, value in self.config.JupyterHubApp.items()
|
||||||
|
)
|
||||||
|
)
|
||||||
self.write_pid_file()
|
self.write_pid_file()
|
||||||
self.init_ports()
|
self.init_ports()
|
||||||
self.init_secrets()
|
self.init_secrets()
|
||||||
@@ -822,7 +827,7 @@ class JupyterHubApp(Application):
|
|||||||
# run the cleanup step (in a new loop, because the interrupted one is unclean)
|
# run the cleanup step (in a new loop, because the interrupted one is unclean)
|
||||||
IOLoop().run_sync(self.cleanup)
|
IOLoop().run_sync(self.cleanup)
|
||||||
|
|
||||||
main = JupyterHubApp.launch_instance
|
main = JupyterHub.launch_instance
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@@ -11,7 +11,7 @@ from tornado import ioloop
|
|||||||
|
|
||||||
from .. import orm
|
from .. import orm
|
||||||
|
|
||||||
from .mocking import MockHubApp
|
from .mocking import MockHub
|
||||||
|
|
||||||
|
|
||||||
# global db session object
|
# global db session object
|
||||||
@@ -46,7 +46,7 @@ def io_loop():
|
|||||||
|
|
||||||
@fixture(scope='module')
|
@fixture(scope='module')
|
||||||
def app(request):
|
def app(request):
|
||||||
app = MockHubApp.instance(log_level=logging.DEBUG)
|
app = MockHub.instance(log_level=logging.DEBUG)
|
||||||
app.start([])
|
app.start([])
|
||||||
request.addfinalizer(app.stop)
|
request.addfinalizer(app.stop)
|
||||||
return app
|
return app
|
||||||
|
@@ -9,7 +9,7 @@ from unittest import mock
|
|||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
from ..spawner import LocalProcessSpawner
|
from ..spawner import LocalProcessSpawner
|
||||||
from ..app import JupyterHubApp
|
from ..app import JupyterHub
|
||||||
from ..auth import PAMAuthenticator
|
from ..auth import PAMAuthenticator
|
||||||
from .. import orm
|
from .. import orm
|
||||||
|
|
||||||
@@ -50,8 +50,8 @@ class MockPAMAuthenticator(PAMAuthenticator):
|
|||||||
with mock.patch('simplepam.authenticate', mock_authenticate):
|
with mock.patch('simplepam.authenticate', mock_authenticate):
|
||||||
return super(MockPAMAuthenticator, self).authenticate(*args, **kwargs)
|
return super(MockPAMAuthenticator, self).authenticate(*args, **kwargs)
|
||||||
|
|
||||||
class MockHubApp(JupyterHubApp):
|
class MockHub(JupyterHub):
|
||||||
"""HubApp with various mock bits"""
|
"""Hub with various mock bits"""
|
||||||
|
|
||||||
db_file = None
|
db_file = None
|
||||||
|
|
||||||
@@ -74,14 +74,14 @@ class MockHubApp(JupyterHubApp):
|
|||||||
def _start():
|
def _start():
|
||||||
self.io_loop = IOLoop.current()
|
self.io_loop = IOLoop.current()
|
||||||
# put initialize in start for SQLAlchemy threading reasons
|
# put initialize in start for SQLAlchemy threading reasons
|
||||||
super(MockHubApp, self).initialize(argv=argv)
|
super(MockHub, self).initialize(argv=argv)
|
||||||
|
|
||||||
# add an initial user
|
# add an initial user
|
||||||
user = orm.User(name='user')
|
user = orm.User(name='user')
|
||||||
self.db.add(user)
|
self.db.add(user)
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
self.io_loop.add_callback(evt.set)
|
self.io_loop.add_callback(evt.set)
|
||||||
super(MockHubApp, self).start()
|
super(MockHub, self).start()
|
||||||
|
|
||||||
self._thread = threading.Thread(target=_start)
|
self._thread = threading.Thread(target=_start)
|
||||||
self._thread.start()
|
self._thread.start()
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
"""Test the JupyterHubApp entry point"""
|
"""Test the JupyterHub entry point"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -8,7 +8,7 @@ from tempfile import NamedTemporaryFile
|
|||||||
def test_help_all():
|
def test_help_all():
|
||||||
out = check_output([sys.executable, '-m', 'jupyterhub', '--help-all']).decode('utf8', 'replace')
|
out = check_output([sys.executable, '-m', 'jupyterhub', '--help-all']).decode('utf8', 'replace')
|
||||||
assert '--ip' in out
|
assert '--ip' in out
|
||||||
assert '--JupyterHubApp.ip' in out
|
assert '--JupyterHub.ip' in out
|
||||||
|
|
||||||
def test_generate_config():
|
def test_generate_config():
|
||||||
with NamedTemporaryFile(prefix='jupyterhub_config', suffix='.py') as tf:
|
with NamedTemporaryFile(prefix='jupyterhub_config', suffix='.py') as tf:
|
||||||
|
Reference in New Issue
Block a user