From 5a7423069ceb7b53822c9aad29428fcbbfc9388d Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Mon, 9 Oct 2023 13:50:39 +0300 Subject: [PATCH] Fix defaultInterpreterPath in vscode --- clearml_session/interactive_session_task.py | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/clearml_session/interactive_session_task.py b/clearml_session/interactive_session_task.py index 5a5306d..e7c297b 100644 --- a/clearml_session/interactive_session_task.py +++ b/clearml_session/interactive_session_task.py @@ -379,6 +379,7 @@ def start_vscode_server(hostname, hostnames, param, task, env, bind_ip="127.0.0. ) if user_folder: + # set user level configuration settings = Path(os.path.expanduser(os.path.join(user_folder, 'User/settings.json'))) settings.parent.mkdir(parents=True, exist_ok=True) # noinspection PyBroadException @@ -404,6 +405,27 @@ def start_vscode_server(hostname, hostnames, param, task, env, bind_ip="127.0.0. except Exception: pass + # set machine level configuration + settings = Path(os.path.expanduser(os.path.join(user_folder, 'Machine/settings.json'))) + 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 = {} + + # noinspection PyBroadException + try: + # "python.defaultInterpreterPath" is a machine level setting + base_json.update({ + "python.defaultInterpreterPath": sys.executable, + }) + with open(settings.as_posix(), 'wt') as f: + json.dump(base_json, f) + except Exception: + pass + proc = subprocess.Popen( ['bash', '-c', '{} --auth none --bind-addr {}:{} --disable-update-check {} {}'.format(