Skip to content

Commit

Permalink
Merge pull request #1 from lexming/vub-hpc
Browse files Browse the repository at this point in the history
Fix support for JupyterHub 3
  • Loading branch information
wpoely86 authored Jun 2, 2023
2 parents 20013a4 + d7e9caa commit dfa9c0a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.5"
- "3.9"
- "3.6"
- "3.10"
JHUB_VER:
- "0.9.6"
- "1.0.0"
- "1.1.0"
- "1.2.0"
- "1.3.0"
- "1.5.1"
- "2.3.1"
allow_failure: [false]

exclude:
Expand All @@ -53,6 +51,9 @@ jobs:
- JHUB_VER: "main"
python-version: "3.9"
allow_failure: true
- JHUB_VER: "3.0.0"
python-version: "3.9"
allow_failure: true

steps:
- uses: actions/checkout@v3
Expand Down
20 changes: 15 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,32 @@
repos:
# Autoformat: Python code
- repo: https://github.com/psf/black
rev: "22.8.0"
rev: "22.12.0"
hooks:
- id: black
args: [--target-version=py36]
args:
- --target-version=py36
- --target-version=py37
- --target-version=py38
- --target-version=py39
- --target-version=py310
- --target-version=py311

# Autoformat: markdown, yaml
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.0
rev: v3.0.0-alpha.4
hooks:
- id: prettier

# Lint: Python code
- repo: https://github.com/PyCQA/flake8
rev: "5.0.4"
rev: "6.0.0"
hooks:
- id: flake8

# Misc...
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
# ref: https://github.com/pre-commit/pre-commit-hooks#hooks-available
hooks:
# Autoformat: Makes sure files end in a newline and only a newline.
Expand All @@ -48,3 +54,7 @@ repos:

# Lint: Checks that non-binary executables have a proper shebang.
- id: check-executables-have-shebangs

# pre-commit.ci config reference: https://pre-commit.ci/#configuration
ci:
autoupdate_schedule: monthly
20 changes: 17 additions & 3 deletions batchspawner/singleuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,31 @@
from jupyterhub.utils import random_port, url_path_join
from jupyterhub.services.auth import HubAuth

import requests


def main(argv=None):
port = random_port()
hub_auth = HubAuth()
hub_auth.client_ca = os.environ.get("JUPYTERHUB_SSL_CLIENT_CA", "")
hub_auth.certfile = os.environ.get("JUPYTERHUB_SSL_CERTFILE", "")
hub_auth.keyfile = os.environ.get("JUPYTERHUB_SSL_KEYFILE", "")
hub_auth._api_request(
method="POST",
url=url_path_join(hub_auth.api_url, "batchspawner"),

url = url_path_join(hub_auth.api_url, "batchspawner")
headers = {"Authorization": f"token {hub_auth.api_token}"}

# internal_ssl kwargs
kwargs = {}
if hub_auth.certfile and hub_auth.keyfile:
kwargs["cert"] = (hub_auth.certfile, hub_auth.keyfile)
if hub_auth.client_ca:
kwargs["verify"] = hub_auth.client_ca

r = requests.post(
url,
headers={"Authorization": f"token {hub_auth.api_token}"},
json={"port": port},
**kwargs,
)

cmd_path = which(sys.argv[1])
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
version_info = (
1,
2,
1,
2,
# "dev", # comment-out this line for a release
)
__version__ = ".".join(map(str, version_info))

0 comments on commit dfa9c0a

Please sign in to comment.