Skip to content

Commit

Permalink
squashme: use the amalthea session cache
Browse files Browse the repository at this point in the history
  • Loading branch information
olevski committed Sep 18, 2024
1 parent 7d1d24c commit e3ad92f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,13 @@ def __init__(self, url: str, server_type: type[_SessionType]):
self.url = url
self.client = httpx.AsyncClient()
self.server_type: type[_SessionType] = server_type
self.url_path_name = "servers"
if server_type == AmaltheaSessionV1Alpha1:
self.url_path_name = "sessions"

async def list_servers(self, safe_username: str) -> list[_SessionType]:
"""List the jupyter servers."""
url = urljoin(self.url, f"/users/{safe_username}/servers")
url = urljoin(self.url, f"/users/{safe_username}/{self.url_path_name}")
try:
res = await self.client.get(url, timeout=10)
except httpx.RequestError as err:
Expand All @@ -372,7 +375,7 @@ async def list_servers(self, safe_username: str) -> list[_SessionType]:

async def get_server(self, name: str) -> _SessionType | None:
"""Get a specific jupyter server."""
url = urljoin(self.url, f"/servers/{name}")
url = urljoin(self.url, f"/{self.url_path_name}/{name}")
try:
res = await self.client.get(url, timeout=10)
except httpx.RequestError as err:
Expand Down

0 comments on commit e3ad92f

Please sign in to comment.