Skip to content

Commit

Permalink
Fix cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Aug 15, 2024
1 parent c9d6a5d commit eca1a5b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions template/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,6 @@ async def create_context(request: CreateContext) -> Context:
session_id = session_data["id"]
kernel_id = session_data["kernel"]["id"]

response = await client.patch(
f"{JUPYTER_BASE_URL}/api/sessions/{session_id}",
json={"path": request.cwd},
)
if not response.is_success:
raise HTTPException(
status_code=500,
detail=f"Failed to create kernel: {response.text}",
)

logger.debug(f"Created kernel {kernel_id}")

ws = JupyterKernelWebSocket(
Expand All @@ -145,6 +135,13 @@ async def create_context(request: CreateContext) -> Context:

websockets[kernel_id] = ws

async for item in ws.execute(f"%cd {request.cwd}", background=True):
if item["type"] == "error":
raise HTTPException(
status_code=500,
detail=f"Failed to set working directory: {item}",
)

return Context(name=request.name, id=kernel_id, cwd=request.cwd)


Expand Down

0 comments on commit eca1a5b

Please sign in to comment.