Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ The user-visible changes of canoP, by version (see `CONTRIBUTING.md` for the ver
OpenMP and HIP.
- canoP studio: GPUs can also be requested with `--gpus-per-node` (Slurm request `gpus-per-node`), as
Adastra requires.
- canoP studio in VS Code Remote-SSH: the studio no longer takes the server of VS Code
(`~/.vscode-server/.../bin/code-server`) for code-server, whose address the canoP icon opened instead
of the port of the studio that VS Code forwards (extension 0.1.3).
- canoP studio in English or in French: a FR/EN switch in the top bar, saved in the settings. New
installations start in English; studios set up before keep French.
- Tutorial of canoP studio in the documentation: the build, a run of the blast example, and a
Expand Down
18 changes: 12 additions & 6 deletions tools/trame/canop_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from vtkmodules.vtkFiltersParallel import vtkMergeBlocks # noqa: E402
from vtkmodules.vtkIOXdmf2 import vtkXdmfReader # noqa: E402

from canop_launch import CONFIG_DIR # noqa: E402 (in the clone or for the account)
from canop_launch import CONFIG_DIR, vscode_server_program # noqa: E402 (CONFIG_DIR: in the clone or for the account)
SETTINGS_FILE = os.path.join(CONFIG_DIR, "settings.json")

# arrays written by kalypsso for debugging the mesh, hidden from the field list
Expand Down Expand Up @@ -1524,12 +1524,11 @@ def code_server_proxy():
"""URL pattern of the code-server port proxy ('.../proxy/{{port}}/'), or None.

None when no code-server of this user runs on this node: its proxy only reaches ports of the node
it runs on.
it runs on. The server of VS Code Remote-SSH (~/.vscode-server/.../bin/code-server) is not one: it
has no proxy, and VS Code forwards the port of the studio instead.
"""
uri = os.environ.get("VSCODE_PROXY_URI", "")
if "{{port}}" in uri and uri.startswith("http"):
return uri
bind = None
found = False
# a running code-server of this user, given --bind-addr on its command line
for pid in os.listdir("/proc") if os.path.isdir("/proc") else []:
if not pid.isdigit():
Expand All @@ -1541,15 +1540,22 @@ def code_server_proxy():
argv = fd.read().decode(errors="replace").split("\0")
except OSError:
continue
if not any("code-server" in a for a in argv[:2]):
if not any("code-server" in a for a in argv[:2]) or any(vscode_server_program(a) for a in argv[:2]):
continue
found = True
for i, a in enumerate(argv):
if a == "--bind-addr" and i + 1 < len(argv):
bind = argv[i + 1]
elif a.startswith("--bind-addr="):
bind = a.split("=", 1)[1]
if bind:
break
if not found:
return None
# the address of code-server as the browser sees it, given by code-server to its terminals
uri = os.environ.get("VSCODE_PROXY_URI", "")
if "{{port}}" in uri and uri.startswith("http"):
return uri
if not bind:
return None
return "http://%s/proxy/{{port}}/" % bind
Expand Down
11 changes: 10 additions & 1 deletion tools/trame/canop_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
_REMOTE_SERVER = re.compile(r"/\.(vscode-server|vscode-server-insiders|cursor-server|windsurf-server)/")


def vscode_server_program(path):
"""True when path is in the directory of the server that VS Code Remote-SSH (or a fork) runs on the node.

That server is not code-server, though its launcher is also named code-server
(~/.vscode-server/cli/servers/<version>/server/bin/code-server): it has no port proxy.
"""
return bool(_REMOTE_SERVER.search(path))


def vscode_remote(pid=None):
"""True when the process runs under the server of VS Code Remote-SSH: the program of one of its ancestors
is in ~/.vscode-server/ (or that of a fork of VS Code), as the node of the server and of its extension
Expand All @@ -48,7 +57,7 @@ def vscode_remote(pid=None):
ppid = int(fd.read().rsplit(")", 1)[1].split()[1])
except (OSError, ValueError, IndexError): # no /proc (macOS), or the process is gone
return False
if _REMOTE_SERVER.search(program):
if vscode_server_program(program):
return True
if ppid <= 1:
return False
Expand Down
2 changes: 1 addition & 1 deletion tools/trame/canop_mcp_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _addresses(info, remote=None):
"""
remote = vscode_remote() if remote is None else remote
lines = []
if info.get("url_code_server"):
if info.get("url_code_server") and not remote:
lines.append("via code-server (à ouvrir dans VS Code : Ctrl+Shift+P > Simple Browser: Show) : "
+ info["url_code_server"])
if remote:
Expand Down
5 changes: 3 additions & 2 deletions tools/vscode/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ class Panel {
}

async function browserUrl(info) {
if (info.url_code_server) return info.url_code_server;
// VS Code (remote SSH or local): let it forward the port
// code-server: its port proxy; VS Code (Remote-SSH or local): let VS Code forward the port of the
// studio, even when the studio found a code-server address
if (info.url_code_server && vscode.env.remoteName !== "ssh-remote") return info.url_code_server;
const uri = await vscode.env.asExternalUri(vscode.Uri.parse(info.url_direct));
return uri.toString(true);
}
Expand Down
2 changes: 1 addition & 1 deletion tools/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "canop-studio",
"displayName": "canoP studio",
"description": "Start canoP studio on the node and open it in the Simple Browser.",
"version": "0.1.2",
"version": "0.1.3",
"publisher": "canop",
"icon": "media/canop.png",
"license": "Apache-2.0 WITH LLVM-exception",
Expand Down
Loading