Skip to content

Commit

Permalink
Add JupyterLab server_side_execution flag
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Dec 1, 2023
1 parent 6a41166 commit 4706d25
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions jupyverse_api/jupyverse_api/jupyterlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,4 @@ async def get_workspace(

class JupyterLabConfig(Config):
dev_mode: bool = False
server_side_execution: bool = False
6 changes: 5 additions & 1 deletion plugins/jupyterlab/fps_jupyterlab/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async def get_lab(
self.get_index(
"default",
self.frontend_config.collaborative,
self.jupyterlab_config.server_side_execution,
self.jupyterlab_config.dev_mode,
self.frontend_config.base_url,
)
Expand All @@ -71,6 +72,7 @@ async def load_workspace(
self.get_index(
"default",
self.frontend_config.collaborative,
self.jupyterlab_config.server_side_execution,
self.jupyterlab_config.dev_mode,
self.frontend_config.base_url,
)
Expand Down Expand Up @@ -99,11 +101,12 @@ async def get_workspace(
return self.get_index(
name,
self.frontend_config.collaborative,
self.jupyterlab_config.server_side_execution,
self.jupyterlab_config.dev_mode,
self.frontend_config.base_url,
)

def get_index(self, workspace, collaborative, dev_mode, base_url="/"):
def get_index(self, workspace, collaborative, server_side_execution, dev_mode, base_url="/"):
for path in (self.static_lab_dir).glob("main.*.js"):
main_id = path.name.split(".")[1]
break
Expand All @@ -121,6 +124,7 @@ def get_index(self, workspace, collaborative, dev_mode, base_url="/"):
"baseUrl": base_url,
"cacheFiles": False,
"collaborative": collaborative,
"serverSideExecution": server_side_execution,
"devMode": dev_mode,
"disabledExtensions": self.disabled_extension,
"exposeAppInBrowser": False,
Expand Down
25 changes: 17 additions & 8 deletions plugins/kernels/fps_kernels/kernel_driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,27 @@ async def _handle_outputs(self, outputs: Array, msg: Dict[str, Any]):
content = msg["content"]
if msg_type == "stream":
with outputs.doc.transaction():
# TODO: uncomment when changes are made in jupyter-ydoc
if (not outputs) or (outputs[-1]["name"] != content["name"]): # type: ignore
outputs.append(
Map(
{
"name": content["name"],
"output_type": msg_type,
"text": Array([content["text"]]),
}
)
#Map(
# {
# "name": content["name"],
# "output_type": msg_type,
# "text": Array([content["text"]]),
# }
#)
{
"name": content["name"],
"output_type": msg_type,
"text": [content["text"]],
}
)
else:
outputs[-1]["text"].append(content["text"]) # type: ignore
#outputs[-1]["text"].append(content["text"]) # type: ignore
last_output = outputs[-1]
last_output["text"].append(content["text"]) # type: ignore
outputs[-1] = last_output
elif msg_type in ("display_data", "execute_result"):
if "application/vnd.jupyter.ywidget-view+json" in content["data"]:
# this is a collaborative widget
Expand Down
2 changes: 1 addition & 1 deletion plugins/yjs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "An FPS plugin for the Yjs API"
keywords = [ "jupyter", "server", "fastapi", "plugins" ]
requires-python = ">=3.8"
dependencies = [
"pycrdt >=0.4.2,<0.5.0",
"pycrdt >=0.5.0,<0.6.0",
"jupyverse-api >=0.1.2,<1",
]
dynamic = [ "version",]
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ test = [
"requests",
"websockets",
"ipykernel",
"ypywidgets >=0.6.1,<0.7.0",
"ypywidgets-textual >=0.2.1,<0.3.0",
"ypywidgets >=0.6.3,<0.7.0",
"ypywidgets-textual >=0.2.2,<0.3.0",
]
docs = [ "mkdocs", "mkdocs-material" ]

Expand Down

0 comments on commit 4706d25

Please sign in to comment.