From b5e4c5db76a5fb41cf13670afd153b21ee6b63ac Mon Sep 17 00:00:00 2001
From: allegroai <>
Date: Mon, 9 Oct 2023 13:46:55 +0300
Subject: [PATCH] Add default jupyter lab settings

---
 clearml_session/interactive_session_task.py | 25 +++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/clearml_session/interactive_session_task.py b/clearml_session/interactive_session_task.py
index 64900e3..2a72708 100644
--- a/clearml_session/interactive_session_task.py
+++ b/clearml_session/interactive_session_task.py
@@ -461,6 +461,31 @@ def start_jupyter_server(hostname, hostnames, param, task, env, bind_ip="127.0.0
         print("Warning: failed setting user base directory [{}] reverting to ~/".format(cwd))
         cwd = os.path.expanduser("~/")
 
+    # setup jupyter-lab default
+    # noinspection PyBroadException
+    try:
+        settings = Path(os.path.expanduser(
+            "~/.jupyter/lab/user-settings/@jupyterlab/apputils-extension/notification.jupyterlab-settings"))
+        settings.parent.mkdir(parents=True, exist_ok=True)
+        # noinspection PyBroadException
+        try:
+            with open(settings.as_posix(), 'rt') as f:
+                base_json = json.load(f)
+        except Exception:
+            base_json = {}
+
+        # Notice we are Not using "python.defaultInterpreterPath": sys.executable,
+        # because for some reason it breaks the auto python interpreter setup
+        base_json.update({
+            "checkForUpdates": False,
+            "doNotDisturbMode": False,
+            "fetchNews": "false"
+        })
+        with open(settings.as_posix(), 'wt') as f:
+            json.dump(base_json, f)
+    except Exception as ex:
+        print("WARNING: Could not set default jupyter lab settings: {}".format(ex))
+
     print(
         "Running Jupyter Notebook Server on {} [{}] port {} at {}".format(hostname, hostnames, port, cwd)
     )