Skip to content

Commit

Permalink
[DM-27353] Allow override of jupyter URL
Browse files Browse the repository at this point in the history
This will allow us to pass an option to point to a different
URL to contact for notebooks, allowing us to run nublado vs
nublado2, which are at different endpoints for now.
  • Loading branch information
cbanek committed Oct 30, 2020
1 parent 9403ac7 commit 64f088f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/mobu/jupyterclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import string
from dataclasses import dataclass
from http.cookies import BaseCookie
from typing import Any, Dict
from uuid import uuid4

from aiohttp import ClientSession
Expand All @@ -33,14 +34,18 @@ class JupyterClient:
log: BoundLoggerLazyProxy
user: User
session: ClientSession
headers: dict
headers: Dict[str, str]
xsrftoken: str
jupyter_url: str

def __init__(self, user: User, log: BoundLoggerLazyProxy):
def __init__(
self, user: User, log: BoundLoggerLazyProxy, options: Dict[str, Any]
):
self.user = user
self.log = log
self.jupyter_url = Configuration.environment_url + "/nb/"
self.jupyter_url = Configuration.environment_url + options.get(
"nb_url", "/nb/"
)
self.xsrftoken = "".join(
random.choices(string.ascii_uppercase + string.digits, k=16)
)
Expand Down
4 changes: 3 additions & 1 deletion src/mobu/jupyterloginloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ async def run(self) -> None:
try:
logger = self.monkey.log
logger.info("Starting up...")
self._client = JupyterClient(self.monkey.user, logger)
self._client = JupyterClient(
self.monkey.user, logger, self.options
)

await self._client.hub_login()
logger.info("Logged into hub")
Expand Down
2 changes: 1 addition & 1 deletion src/mobu/jupyterpythonloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async def run(self) -> None:
logger = self.monkey.log
logger.info("Starting up...")

client = JupyterClient(self.monkey.user, logger)
client = JupyterClient(self.monkey.user, logger, self.options)
await client.hub_login()
await client.ensure_lab()

Expand Down
4 changes: 3 additions & 1 deletion src/mobu/notebookrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ async def run(self) -> None:
try:
logger = self.monkey.log

self._client = JupyterClient(self.monkey.user, logger)
self._client = JupyterClient(
self.monkey.user, logger, self.options
)

if not self._repo:
self._repo = git.Repo.clone_from(
Expand Down

0 comments on commit 64f088f

Please sign in to comment.