update: jupyter api payload, wire os.environ
This commit is contained in:
@@ -195,7 +195,8 @@ async def start_workspace(ws_id: str) -> dict:
|
||||
base_path = f"/jupyter/{ws_id}/"
|
||||
|
||||
cmd = [
|
||||
"jupyter", "notebook",
|
||||
"jupyter",
|
||||
"notebook",
|
||||
f"--port={port}",
|
||||
"--ip=0.0.0.0",
|
||||
"--no-browser",
|
||||
@@ -212,12 +213,14 @@ async def start_workspace(ws_id: str) -> dict:
|
||||
]
|
||||
|
||||
try:
|
||||
process, log_file = start_process(cmd, workspace_path.as_posix())
|
||||
process, log_file = start_process(
|
||||
cmd,
|
||||
workspace_path.as_posix(),
|
||||
env={"PATH": f"/app/.venv/bin:{os.environ.get('PATH', '')}"},
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to start Jupyter for {ws_id}: {e}")
|
||||
raise HTTPException(
|
||||
status_code=500, detail=f"Failed to start Jupyter: {e}"
|
||||
)
|
||||
raise HTTPException(status_code=500, detail=f"Failed to start Jupyter: {e}")
|
||||
|
||||
full_url = f"{PUBLIC_BASE_URL}:{port}{base_path}?token={token}"
|
||||
meta_path = _meta_path(ws_id)
|
||||
@@ -341,8 +344,7 @@ async def get_workspace(ws_id: str) -> dict:
|
||||
raise HTTPException(
|
||||
status_code=404,
|
||||
detail=(
|
||||
f"Jupyter process for workspace '{ws_id}' "
|
||||
"has terminated unexpectedly."
|
||||
f"Jupyter process for workspace '{ws_id}' " "has terminated unexpectedly."
|
||||
),
|
||||
)
|
||||
|
||||
@@ -416,7 +418,9 @@ def reconcile_processes() -> dict[str, int]:
|
||||
except PermissionError:
|
||||
alive = True # someone else's process, leave alone
|
||||
if not alive:
|
||||
logger.info(f"reconcile: dropping stale sidecar for {entry} (pid {pid} dead)")
|
||||
logger.info(
|
||||
f"reconcile: dropping stale sidecar for {entry} (pid {pid} dead)"
|
||||
)
|
||||
_delete_meta(entry)
|
||||
counters["removed_meta"] += 1
|
||||
return counters
|
||||
|
||||
Reference in New Issue
Block a user