modified jupyter helper for collaboration >=2.x

This commit is contained in:
2023-11-14 16:20:13 +01:00
parent aa6190e9dd
commit 4d5263e620

View File

@@ -4,14 +4,28 @@ To use:
jupyter lab --YDocExtension.ystore_class=cristallina.jupyter_helper.MySQLiteYStore
In 2.0.x this is replaced by:
# The Store class used for storing Y updates (default: SQLiteYStore).
jupyter lab --YDocExtension.ystore_class=jupyter_collaboration.stores.FileYStore
This should work on the local consoles and also on RA (yet untested).
"""
from packaging.version import Version
import random
from ypy_websocket.ystore import SQLiteYStore
import jupyter_collaboration
if Version(jupyter_collaboration.__version__) < Version("1.9"):
from ypy_websocket.ystore import SQLiteYStore
else:
# approach for >=2.0
from jupyter_collaboration.stores import SQLiteYStore
class MySQLiteYStore(SQLiteYStore):
"""
Custom SQL location for jupyter collaboration to avoid NFS locking issues.
"""
suffix = random.randint(0, 1E9)
db_path = f"/tmp/ystore_{suffix}.db"