Skip to content

Commit

Permalink
Merge branch 'main' into config-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rsarm authored Jun 12, 2024
2 parents aacd9a1 + 42d795a commit 05d38d8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker image
run: docker build -t ghcr.io/${{ github.repository_owner }}/f7t4fjhub:${{ env.APP_VERSION }} -f dockerfiles/Dockerfile .
run: docker build -t ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }} -f dockerfiles/Dockerfile .

- name: Push Docker image to GitHub Container Registry
run: docker push ghcr.io/${{ github.repository_owner }}/f7t4fjhub:${{ env.APP_VERSION }}
run: docker push ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }}
2 changes: 1 addition & 1 deletion firecrestspawner/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def post(self):
if hasattr(spawner, key):
setattr(spawner, key, value)

self.finish(json.dumps({"message": "BatchSpawner data configured"}))
self.finish(json.dumps({"message": "FirecRESTSpawner data configured"}))
self.set_status(201)


Expand Down
19 changes: 9 additions & 10 deletions firecrestspawner/singleuser.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import os
import sys
import requests

from runpy import run_path
from shutil import which
from urllib.parse import urlparse

from jupyterhub.utils import random_port, url_path_join
import requests
from jupyterhub.services.auth import HubAuth
from jupyterhub.utils import url_path_join


def main(argv=None):
port = random_port()
url = urlparse(os.environ["JUPYTERHUB_SERVICE_URL"])
port = url.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', '')
requests.post(
url=url_path_join(hub_auth.api_url, 'firecrestspawner'),
headers = {"Authorization": f"token {hub_auth.api_token}"},
url=url_path_join(hub_auth.api_url, "firecrestspawner"),
headers={"Authorization": f"token {hub_auth.api_token}"},
json={"port": port},
)
cmd_path = which(sys.argv[1])
sys.argv = sys.argv[1:] + ['--port={}'.format(port)]
sys.argv = sys.argv[1:] + ["--port={}".format(port)]
run_path(cmd_path, run_name="__main__")


if __name__ == "__main__":
main()
22 changes: 6 additions & 16 deletions firecrestspawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import firecrest as f7t
from enum import Enum
from jinja2 import Template
from tornado import gen
# from tornado import gen
from jupyterhub.spawner import Spawner
from traitlets import (
Any, Integer, Unicode, Float, default
Expand Down Expand Up @@ -341,7 +341,7 @@ async def start(self):
if self.port == 0:
self.port = self.traits()['port'].default_value

if jupyterhub.version_info >= (0, 8) and self.server:
if self.server:
self.server.port = self.port

await self.submit_batch_script()
Expand Down Expand Up @@ -369,20 +369,10 @@ async def start(self):
raise RuntimeError('The Jupyter batch job has disappeared'
' while pending in the queue or died '
' immediately after starting.')
await gen.sleep(self.startup_poll_interval)
await asyncio.sleep(self.startup_poll_interval)

self.ip = await self.state_gethost()
while self.port == 0:
await gen.sleep(self.startup_poll_interval)
# Test framework: For testing, mock_port is set because we
# don't actually run the single-user server yet.
if hasattr(self, 'mock_port'):
self.port = self.mock_port

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

self.db.commit()
self.log.info(f"Notebook server job {self.job_id} started at "
f"{self.ip}:{self.port}")
Expand All @@ -403,7 +393,7 @@ async def stop(self, now=False):
status = await self.query_job_status()
if status not in (JobStatus.RUNNING, JobStatus.UNKNOWN):
return
await gen.sleep(1.0)
await asyncio.sleep(1.0)
if self.job_id:
self.log.warning(
f"Notebook server job {self.job_id} at {self.ip}:{self.port} "
Expand All @@ -426,7 +416,7 @@ async def progress(self):
await yield_({
"message": "Unknown status...",
})
await gen.sleep(1)
await asyncio.sleep(1)


class FirecRESTSpawnerRegexStates(FirecRESTSpawnerBase):
Expand Down

0 comments on commit 05d38d8

Please sign in to comment.