Skip to content

Commit

Permalink
Merge pull request #488 from consideRatio/pr/req-py38-jh231
Browse files Browse the repository at this point in the history
Require python 3.8+ and jupyterhub 2.3.1+
  • Loading branch information
consideRatio committed May 31, 2023
2 parents 3544040 + 9f98b23 commit 2c4839a
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 36 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test.yaml
Expand Up @@ -31,10 +31,8 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: "3.7"
pip-install-spec: "jupyterhub==1.0.0 sqlalchemy==1.*"
- python-version: "3.8"
pip-install-spec: "jupyterhub==2.* sqlalchemy==1.*"
pip-install-spec: "jupyterhub==2.3.1 sqlalchemy==1.*"
- python-version: "3.9"
pip-install-spec: "jupyterhub==3.*"
- python-version: "3.11"
Expand Down
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -25,7 +25,7 @@ for more information about features and usage.

## Prerequisites

JupyterHub 0.7 or above is required, which also means Python 3.3 or above.
Python 3.8 or above and JupyterHub 2.3.1 or above is required.

## Installation

Expand All @@ -50,8 +50,7 @@ All code is licensed under the terms of the revised BSD license.

## Getting help

We encourage you to ask questions on the [Discourse community forum](https://discourse.jupyter.org/),
or [Gitter](https://gitter.im/jupyterhub/jupyterhub).
We encourage you to ask questions on the [Discourse community forum](https://discourse.jupyter.org/).

## Resources

Expand Down
16 changes: 5 additions & 11 deletions dockerspawner/dockerspawner.py
Expand Up @@ -656,12 +656,11 @@ def _legacy_escape(text):

@observe("hub_ip_connect")
def _ip_connect_changed(self, change):
if jupyterhub.version_info >= (0, 8):
warnings.warn(
"DockerSpawner.hub_ip_connect is no longer needed with JupyterHub 0.8."
" Use JupyterHub.hub_connect_ip instead.",
DeprecationWarning,
)
warnings.warn(
"DockerSpawner.hub_ip_connect is no longer needed with JupyterHub 0.8."
" Use JupyterHub.hub_connect_ip instead.",
DeprecationWarning,
)

use_internal_ip = Bool(
False,
Expand Down Expand Up @@ -1316,11 +1315,6 @@ async def start(self, image=None, extra_create_kwargs=None, extra_host_config=No
await self.post_start_exec()

ip, port = await self.get_ip_and_port()
if jupyterhub.version_info < (0, 7):
# store on user for pre-jupyterhub-0.7:
self.user.server.ip = ip
self.user.server.port = port
# jupyterhub 0.7 prefers returning ip, port:
return (ip, port)

@property
Expand Down
4 changes: 2 additions & 2 deletions examples/internal-ssl/.env
Expand Up @@ -13,7 +13,7 @@ DOCKER_MACHINE_NAME=jupyterhub
DOCKER_NETWORK_NAME=jupyterhub

# Single-user Jupyter Notebook server container image
DOCKER_NOTEBOOK_IMAGE=jupyterhub/singleuser:1
DOCKER_NOTEBOOK_IMAGE=jupyterhub/singleuser:4

# Name of JupyterHub container data volume
DATA_VOLUME_HOST=jupyterhub-data
Expand All @@ -28,4 +28,4 @@ SSL_VOLUME_HOST=jupyterhub-ssl
SSL_VOLUME_CONTAINER=/jupyterhub-ssl


CONFIGPROXY_AUTH_TOKEN=t2ycxpHi0PnGcxPuJQzVxd9kpeuyqG75FQFyeoOOUI
CONFIGPROXY_AUTH_TOKEN=abc123
8 changes: 4 additions & 4 deletions examples/internal-ssl/Dockerfile
@@ -1,7 +1,7 @@
FROM jupyterhub/jupyterhub:1
COPY setup.py /src/dockerspawner/setup.py
COPY requirements.txt /src/dockerspawner/requirements.txt
RUN pip install -r /src/dockerspawner/requirements.txt
FROM jupyterhub/jupyterhub:4

COPY setup.py requirements.txt /src/dockerspawner/
COPY dockerspawner /src/dockerspawner/dockerspawner
RUN pip install /src/dockerspawner

COPY examples/internal-ssl/jupyterhub_config.py /srv/jupyterhub/jupyterhub_config.py
7 changes: 4 additions & 3 deletions examples/internal-ssl/README.md
Expand Up @@ -11,10 +11,11 @@ with configurable-http-proxy and total internal encryption.
To use it:

docker network create jupyterhub
docker volume create jupyterhub-ssl jupyterhub-data
docker volume create jupyterhub-ssl
docker volume create jupyterhub-data

docker-compose build
docker-compose up
docker compose build
docker compose up

and then visit http://127.0.0.1:8000

Expand Down
2 changes: 1 addition & 1 deletion examples/internal-ssl/docker-compose.yml
Expand Up @@ -11,7 +11,7 @@ services:
condition: service_completed_successfully

container_name: proxy
image: jupyterhub/configurable-http-proxy:4.5.0
image: jupyterhub/configurable-http-proxy:4
restart: always
environment:
CONFIGPROXY_AUTH_TOKEN: ${CONFIGPROXY_AUTH_TOKEN}
Expand Down
20 changes: 16 additions & 4 deletions examples/internal-ssl/test_internal_ssl.py
Expand Up @@ -9,7 +9,7 @@
import requests

here = os.path.dirname(__file__)
hub_url = 'http://127.0.0.1:8000'
hub_url = 'http://localhost:8000'


@pytest.fixture(scope='session')
Expand Down Expand Up @@ -74,10 +74,22 @@ def compose_up(volumes_and_networks, compose_build):

def test_internal_ssl(compose_up):
s = requests.Session()
r = s.post(hub_url + '/hub/login', data={'username': 'fake', 'password': 'ok'})

# acquire a _xsrf cookie to pass in the post request we are about to make
r = s.get(hub_url + '/hub/login')
r.raise_for_status()
_xsrf_cookie = s.cookies.get("_xsrf", path="/hub/")
assert _xsrf_cookie

r = s.post(
hub_url + '/hub/login',
data={'username': 'fake', 'password': 'ok', '_xsrf': _xsrf_cookie},
)
r.raise_for_status()

while "pending" in r.url:
time.sleep(0.1)
# request again
time.sleep(2)
r = s.get(r.url)
r.raise_for_status()
assert urlparse(r.url).path == '/user/fake/tree'
assert urlparse(r.url).path == '/user/fake/lab'
2 changes: 1 addition & 1 deletion examples/swarm/.env
@@ -1 +1 @@
CONFIGPROXY_AUTH_TOKEN=08168e511a2547629ae10f4e631c647363833acdb408b8f5be277838e3e1a57f
CONFIGPROXY_AUTH_TOKEN=abc123
2 changes: 1 addition & 1 deletion examples/swarm/docker-compose.yml
Expand Up @@ -2,7 +2,7 @@ version: "3"
services:
proxy:
env_file: .env
image: jupyterhub/configurable-http-proxy:4.5
image: jupyterhub/configurable-http-proxy:4
networks:
- jupyterhub-net
# expose the proxy to the world
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Expand Up @@ -13,7 +13,6 @@ profile = "black"
[tool.black]
skip-string-normalization = true
target_version = [
"py37",
"py38",
"py39",
"py310",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,3 +1,3 @@
docker
escapism
jupyterhub>=1.0
jupyterhub>=2.3.1
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -78,7 +78,7 @@ def run(self):
'docker-swarm = dockerspawner:SwarmSpawner',
],
},
python_requires=">=3.6",
python_requires=">=3.8",
cmdclass={
'bdist_egg': bdist_egg if 'bdist_egg' in sys.argv else bdist_egg_disabled,
},
Expand Down
3 changes: 3 additions & 0 deletions tests/test_dockerspawner.py
Expand Up @@ -52,6 +52,7 @@ async def test_start_stop(dockerspawner_configured_app, remove):
pending = r.status_code == 202
while pending:
# request again
await asyncio.sleep(2)
r = await api_request(app, "users", name)
user_info = r.json()
pending = user_info["servers"][server_name]["pending"]
Expand All @@ -70,6 +71,7 @@ async def test_start_stop(dockerspawner_configured_app, remove):
pending = r.status_code == 202
while pending:
# request again
await asyncio.sleep(2)
r = await api_request(app, "users", name)
user_info = r.json()
pending = user_info["servers"][server_name]["pending"]
Expand Down Expand Up @@ -125,6 +127,7 @@ async def test_allowed_image(dockerspawner_configured_app, allowed_images, image
pending = r.status_code == 202
while pending:
# request again
await asyncio.sleep(2)
r = await api_request(app, "users", name)
user_info = r.json()
pending = user_info["servers"][""]["pending"]
Expand Down
3 changes: 3 additions & 0 deletions tests/test_swarmspawner.py
@@ -1,4 +1,6 @@
"""Tests for SwarmSpawner"""
import asyncio

import pytest
from jupyterhub.tests.mocking import public_url
from jupyterhub.tests.test_api import add_user, api_request
Expand All @@ -22,6 +24,7 @@ async def test_start_stop(swarmspawner_configured_app):
pending = r.status_code == 202
while pending:
# request again
await asyncio.sleep(2)
r = await api_request(app, "users", name)
user_info = r.json()
pending = user_info["servers"][server_name]["pending"]
Expand Down

0 comments on commit 2c4839a

Please sign in to comment.