Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to TLJH 1.0 #224

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions ansible/tljh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@

- name: Run the TLJH installer
shell: |
{{ ansible_python_interpreter }} {{ tljh_installer_dest }} --no-user-env \
{{ ansible_python_interpreter }} {{ tljh_installer_dest }} \
--plugin {{ tljh_plasma }} {{ tljh_repo2docker }}
# TODO: remove when --no-user-env (or equivalent) is available
environment:
TLJH_BOOTSTRAP_PIP_SPEC: "{{ tljh_bootstrap_pip_spec }}"
--version {{ tljh_version }}

- name: Set the idle culler timeout to 1 hour
shell: "tljh-config set services.cull.timeout 3600"
Expand Down
6 changes: 2 additions & 4 deletions ansible/vars/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ tljh_plasma: git+https://github.com/plasmabio/plasma@master#"egg=tljh-plasma&sub
tljh_repo2docker: git+https://github.com/plasmabio/tljh-repo2docker@master
tljh_installer_dest: /srv/tljh-installer.py
tljh_prefix: /opt/tljh
# TODO: update to upstream TLJH links when the --no-user-env (or similar) is available
# See https://github.com/jupyterhub/the-littlest-jupyterhub/pull/528
tljh_bootstrap_pip_spec: git+https://github.com/jtpio/the-littlest-jupyterhub.git@skip-install#"egg=the_littlest_jupyterhub"
tljh_installer_url: https://raw.githubusercontent.com/jtpio/the-littlest-jupyterhub/skip-install/bootstrap/bootstrap.py
tljh_installer_url: https://tljh.jupyter.org/bootstrap.py
tljh_version: 1.0.0

...
9 changes: 5 additions & 4 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
git+https://github.com/jupyterhub/the-littlest-jupyterhub
git+https://github.com/plasmabio/tljh-repo2docker
jupyterhub~=1.5
notebook<7
git+https://github.com/jupyterhub/the-littlest-jupyterhub@1.0.0
git+https://github.com/jtpio/tljh-repo2docker@jupyterhub-4
jupyterhub>=4,<5
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be updated when there is a proper tag on https://github.com/plasmabio/tljh-repo2docker that includes the changes from plasmabio/tljh-repo2docker#65.

notebook
pytest
pytest-aiohttp
pytest-asyncio
pytest-cov
pytest-jupyterhub
requests-mock
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[pytest]
python_files = test_*.py
asyncio_mode = auto
6 changes: 3 additions & 3 deletions tljh-plasma/tljh_plasma/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from jupyterhub.apihandlers import APIHandler
from jupyterhub.handlers.base import BaseHandler
from jupyterhub.orm import Base, Column, Integer, Unicode
from jupyterhub.utils import admin_only
from jupyterhub.scopes import needs_scope
from tljh_repo2docker.docker import list_images
from tornado.web import authenticated

Expand All @@ -32,7 +32,7 @@ class PermissionsHandler(BaseHandler):
"""

@authenticated
@admin_only
@needs_scope("admin-ui")
async def get(self):
include_groups = self.settings.get("include_groups")
all_groups = list_groups(include_groups)
Expand Down Expand Up @@ -60,8 +60,8 @@ class PermissionsAPIHandler(APIHandler):
Handle edits to the mapping of environments and groups.
"""

@admin_only
@authenticated
@needs_scope("admin-ui")
async def post(self):
raw_args = self.request.body.decode("utf-8")
args = json.loads(raw_args)
Expand Down
54 changes: 10 additions & 44 deletions tljh-plasma/tljh_plasma/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,25 @@
import asyncio
import sys

import pytest

from jupyterhub.tests.conftest import (
io_loop,
event_loop,
db,
pytest_collection_modifyitems,
)
from jupyterhub.tests.mocking import MockHub, MockPAMAuthenticator
from jupyterhub.tests.mocking import MockPAMAuthenticator
from tljh_repo2docker.tests.conftest import (
DummyConfig,
minimal_repo,
image_name,
generated_image_name,
remove_all_test_images
)
from tljh_repo2docker.tests.utils import add_environment
from tljh_repo2docker import tljh_custom_jupyterhub_config as tljh_repo2docker_config
from tljh_plasma import tljh_custom_jupyterhub_config as tljh_plasma_config
from traitlets.config import Config


@pytest.fixture(scope="module")
def app(request, io_loop):
"""
Adapted from:
https://github.com/jupyterhub/jupyterhub/blob/8a3790b01ff944c453ffcc0486149e2a58ffabea/jupyterhub/tests/conftest.py#L74
"""

# create a JupyterHub mock instance
mocked_app = MockHub.instance()
c = DummyConfig()
c.JupyterHub = mocked_app

# apply the config from the plugins
tljh_repo2docker_config(c)
tljh_plasma_config(c)

# switch back to the MockPAMAuthenticator for the tests
c.JupyterHub.authenticator_class = MockPAMAuthenticator
@pytest.fixture
async def app(hub_app):
config = Config()

async def make_app():
await mocked_app.initialize([])
await mocked_app.start()
tljh_repo2docker_config(config)
tljh_plasma_config(config)

def fin():
# disconnect logging during cleanup because pytest closes captured FDs prematurely
mocked_app.log.handlers = []
MockHub.clear_instance()
try:
mocked_app.stop()
except Exception as e:
print("Error stopping Hub: %s" % e, file=sys.stderr)
config.JupyterHub.authenticator_class = MockPAMAuthenticator

request.addfinalizer(fin)
io_loop.run_sync(make_app)
return mocked_app
app = await hub_app(config=config)
return app
Loading