Skip to content

Commit

Permalink
Compute document in the backend using y-py
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Jan 19, 2022
1 parent 4d82190 commit 6c0d0d0
Show file tree
Hide file tree
Showing 3 changed files with 407 additions and 28 deletions.
13 changes: 2 additions & 11 deletions jupyter_server/services/contents/filemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import errno
import json
import mimetypes
import os
import shutil
Expand Down Expand Up @@ -447,10 +446,7 @@ def save(self, model, path=""):
raise web.HTTPError(400, u"No file type provided")

if YJS_SUPPORT and path in ROOMS:
if model["type"] == "notebook":
model["content"] = json.loads(ROOMS[path].source)
elif model["type"] == "file":
model["content"] = ROOMS[path].source
model["content"] = ROOMS[path].get_source()

if "content" not in model and model["type"] != "directory":
raise web.HTTPError(400, u"No file content provided")
Expand Down Expand Up @@ -780,12 +776,7 @@ async def save(self, model, path=""):
raise web.HTTPError(400, u"No file type provided")

if YJS_SUPPORT and path in ROOMS:
await ROOMS[path].ready_to_save.wait()
if model["type"] == "notebook":
model["content"] = json.loads(ROOMS[path].source)
elif model["type"] == "file":
model["content"] = ROOMS[path].source
ROOMS[path].ready_to_save.clear()
model["content"] = ROOMS[path].get_source()

if "content" not in model and model["type"] != "directory":
raise web.HTTPError(400, u"No file content provided")
Expand Down
13 changes: 2 additions & 11 deletions jupyter_server/services/contents/largefilemanager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import base64
import io
import json
import os

from anyio.to_thread import run_sync
Expand Down Expand Up @@ -39,10 +38,7 @@ def save(self, model, path=""):
)

if YJS_SUPPORT and path in ROOMS:
if model["type"] == "notebook":
model["content"] = json.loads(ROOMS[path].source)
elif model["type"] == "file":
model["content"] = ROOMS[path].source
model["content"] = ROOMS[path].get_source()

if "content" not in model and model["type"] != "directory":
raise web.HTTPError(400, u"No file content provided")
Expand Down Expand Up @@ -121,12 +117,7 @@ async def save(self, model, path=""):
)

if YJS_SUPPORT and path in ROOMS:
await ROOMS[path].ready_to_save.wait()
if model["type"] == "notebook":
model["content"] = json.loads(ROOMS[path].source)
elif model["type"] == "file":
model["content"] = ROOMS[path].source
ROOMS[path].ready_to_save.clear()
model["content"] = ROOMS[path].get_source()

if "content" not in model and model["type"] != "directory":
raise web.HTTPError(400, u"No file content provided")
Expand Down
Loading

0 comments on commit 6c0d0d0

Please sign in to comment.