arrayview 0.59.0__tar.gz → 0.59.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. {arrayview-0.59.0 → arrayview-0.59.1}/PKG-INFO +1 -1
  2. {arrayview-0.59.0 → arrayview-0.59.1}/pyproject.toml +1 -1
  3. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_platform.py +3 -1
  4. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_rex.py +43 -1
  5. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_vscode_extension.py +1 -1
  6. arrayview-0.59.1/src/arrayview/arrayview-opener.vsix +0 -0
  7. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_rex_remote.py +26 -0
  8. arrayview-0.59.0/src/arrayview/arrayview-opener.vsix +0 -0
  9. {arrayview-0.59.0 → arrayview-0.59.1}/.gitignore +0 -0
  10. {arrayview-0.59.0 → arrayview-0.59.1}/LICENSE +0 -0
  11. {arrayview-0.59.0 → arrayview-0.59.1}/README.md +0 -0
  12. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/ARCHITECTURE.md +0 -0
  13. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/__init__.py +0 -0
  14. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/__main__.py +0 -0
  15. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_analysis.py +0 -0
  16. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_app.py +0 -0
  17. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_bootstrap_app.py +0 -0
  18. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_config.py +0 -0
  19. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_diagnostics.py +0 -0
  20. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_dicom.py +0 -0
  21. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_diff.py +0 -0
  22. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_extra_ports.py +0 -0
  23. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_icon.png +0 -0
  24. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_imaging.py +0 -0
  25. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_instance_registry.py +0 -0
  26. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_io.py +0 -0
  27. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_launch_plan.py +0 -0
  28. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_launch_trace.py +0 -0
  29. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_launcher.py +0 -0
  30. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_lifecycle.py +0 -0
  31. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_overlays.py +0 -0
  32. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_peer_guard.py +0 -0
  33. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_qmri_colormaps/lipari.csv +0 -0
  34. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_qmri_colormaps/navia.csv +0 -0
  35. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_render.py +0 -0
  36. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_analysis.py +0 -0
  37. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_drop.py +0 -0
  38. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_export.py +0 -0
  39. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_loading.py +0 -0
  40. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_persistence.py +0 -0
  41. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_preferences.py +0 -0
  42. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_preload.py +0 -0
  43. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_query.py +0 -0
  44. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_rendering.py +0 -0
  45. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_segmentation.py +0 -0
  46. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_state.py +0 -0
  47. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_vectorfield.py +0 -0
  48. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_routes_websocket.py +0 -0
  49. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_segmentation.py +0 -0
  50. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_server.py +0 -0
  51. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_session.py +0 -0
  52. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_session_spec.py +0 -0
  53. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_shell.html +0 -0
  54. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_source_safety.py +0 -0
  55. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_synthetic_mri.py +0 -0
  56. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_torch.py +0 -0
  57. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_tutorial.py +0 -0
  58. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_vectorfield.py +0 -0
  59. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_view_memory.py +0 -0
  60. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_viewer.html +0 -0
  61. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_vscode.py +0 -0
  62. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_vscode_browser.py +0 -0
  63. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_vscode_signal.py +0 -0
  64. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/_watch.py +0 -0
  65. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/gsap.min.js +0 -0
  66. {arrayview-0.59.0 → arrayview-0.59.1}/src/arrayview/todo.md +0 -0
  67. {arrayview-0.59.0 → arrayview-0.59.1}/tests/capture_patient_loading.py +0 -0
  68. {arrayview-0.59.0 → arrayview-0.59.1}/tests/capture_v_animation.py +0 -0
  69. {arrayview-0.59.0 → arrayview-0.59.1}/tests/conftest.py +0 -0
  70. {arrayview-0.59.0 → arrayview-0.59.1}/tests/make_vectorfield_test_arrays.py +0 -0
  71. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_1d_arrays.py +0 -0
  72. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_api.py +0 -0
  73. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_backend_shared.py +0 -0
  74. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_cli.py +0 -0
  75. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_config.py +0 -0
  76. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_dicom.py +0 -0
  77. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_drop_import.py +0 -0
  78. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_first_slice_warmup.py +0 -0
  79. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_instance_registry.py +0 -0
  80. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_io.py +0 -0
  81. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_large_arrays.py +0 -0
  82. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_launch_blackbox.py +0 -0
  83. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_nifti_meta.py +0 -0
  84. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_nifti_series.py +0 -0
  85. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_peer_guard.py +0 -0
  86. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_safe_server_stop.py +0 -0
  87. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_shared_home_registrations.py +0 -0
  88. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_source_safety.py +0 -0
  89. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_torch.py +0 -0
  90. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_tutorial.py +0 -0
  91. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_view_memory.py +0 -0
  92. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_viewer_port.py +0 -0
  93. {arrayview-0.59.0 → arrayview-0.59.1}/tests/test_vsix_bundle.py +0 -0
  94. {arrayview-0.59.0 → arrayview-0.59.1}/tests/ui_audit.py +0 -0
  95. {arrayview-0.59.0 → arrayview-0.59.1}/tests/v_anim_frames/.gitkeep +0 -0
  96. {arrayview-0.59.0 → arrayview-0.59.1}/tests/visual_smoke.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: arrayview
3
- Version: 0.59.0
3
+ Version: 0.59.1
4
4
  Summary: Fast multi-dimensional array viewer
5
5
  Project-URL: Home, https://github.com/oscarvanderheide/arrayview
6
6
  Project-URL: Source, https://github.com/oscarvanderheide/arrayview
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "arrayview"
7
- version = "0.59.0"
7
+ version = "0.59.1"
8
8
  description = "Fast multi-dimensional array viewer"
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
  requires-python = ">=3.12"
@@ -717,7 +717,9 @@ def _in_rex_remote() -> bool:
717
717
  if _rex_remote_cache is not None:
718
718
  return _rex_remote_cache
719
719
  _rex_remote_cache = False
720
- if os.environ.get("TERM_PROGRAM") != "rex" or not os.environ.get("REX_SERVER"):
720
+ # REX_SERVER is not a reliable marker: a systemd socket-activated Rex server
721
+ # (what ``rex server install`` sets up on Linux) leaves it unset.
722
+ if os.environ.get("TERM_PROGRAM") != "rex":
721
723
  return False
722
724
  import json
723
725
  import shutil
@@ -22,6 +22,7 @@ from __future__ import annotations
22
22
  import base64
23
23
  import json
24
24
  import os
25
+ import re
25
26
  import shutil
26
27
  import subprocess
27
28
  import sys
@@ -114,6 +115,45 @@ def _connected_endpoints() -> set[str]:
114
115
  return endpoints
115
116
 
116
117
 
118
+ def _app_tunnel_address(endpoint: str, ps_output: str | None = None) -> str | None:
119
+ """``unix://`` address of the tunnel the Rex app already holds to *endpoint*.
120
+
121
+ Every ``rex -S ssh://host`` command logs in to the host again, which takes
122
+ many seconds on some machines. The app keeps one ssh tunnel per host, whose
123
+ local socket reaches the same server at once, so commands sent through it
124
+ skip the login. None when no such tunnel is found; callers then use
125
+ *endpoint* itself.
126
+ """
127
+ if ps_output is None:
128
+ try:
129
+ ps_output = subprocess.run(
130
+ ["ps", "-axo", "pid=,ppid=,args="],
131
+ capture_output=True,
132
+ text=True,
133
+ timeout=5,
134
+ ).stdout
135
+ except Exception:
136
+ return None
137
+ rows = []
138
+ for line in ps_output.splitlines():
139
+ parts = line.split(None, 2)
140
+ if len(parts) == 3 and parts[0].isdigit() and parts[1].isdigit():
141
+ rows.append((int(parts[0]), int(parts[1]), parts[2]))
142
+ tunnels = {
143
+ pid
144
+ for pid, _, args in rows
145
+ if args.endswith(f" __internal ssh-tunnel {endpoint}")
146
+ }
147
+ for _, ppid, args in rows:
148
+ if ppid not in tunnels:
149
+ continue
150
+ # The socket path may contain spaces ("Application Support").
151
+ match = re.search(r" -L (/.+?\.sock):/", args)
152
+ if match and os.path.exists(match.group(1)):
153
+ return "unix://" + urllib.parse.quote(match.group(1))
154
+ return None
155
+
156
+
117
157
  def _report_from_event(event: dict) -> tuple[str, str] | None:
118
158
  """(viewer URL, "native" | "browser") from an ArrayView status report."""
119
159
  if event.get("type") != "session_event":
@@ -216,9 +256,11 @@ class Watcher:
216
256
  # -- forwarding and display ------------------------------------------
217
257
 
218
258
  def _start_forward(self, endpoint: str, remote_port: int) -> tuple[subprocess.Popen, int] | None:
259
+ # Through the app's open tunnel when there is one: no new ssh login.
260
+ server = _app_tunnel_address(endpoint) or endpoint
219
261
  proc = subprocess.Popen(
220
262
  [
221
- self.rex, "-S", endpoint, "forward", "open", "--no-open",
263
+ self.rex, "-S", server, "forward", "open", "--no-open",
222
264
  "--port", "0", str(remote_port),
223
265
  ],
224
266
  stdout=subprocess.PIPE,
@@ -59,7 +59,7 @@ _VSCODE_EXT_FRESH_INSTALL = False # True if we just installed it this session
59
59
  _VSCODE_EXT_RELOAD_REQUIRED = False # installed files are newer than the live host
60
60
  _VSCODE_EXT_INSTALL_FAILED = False # automatic install could not complete safely
61
61
  _VSCODE_EXT_NO_LIVE_WINDOW = False # no live host claims this terminal's window id
62
- _VSCODE_EXT_VERSION = "0.15.80" # current bundled extension version
62
+ _VSCODE_EXT_VERSION = "0.15.81" # current bundled extension version
63
63
  _VSCODE_CONFIGURED_PORTS: set[int] = set()
64
64
  # Version-skew notices already printed, so a long-lived process (Jupyter, a
65
65
  # script opening several arrays) states the mismatch once instead of per call.
@@ -65,6 +65,13 @@ def test_app_reaching_server_through_sshd_is_remote(rex_env):
65
65
  assert _platform._in_rex_remote() is True
66
66
 
67
67
 
68
+ def test_remote_without_rex_server_variable(rex_env, monkeypatch):
69
+ # A systemd socket-activated Rex server does not set REX_SERVER.
70
+ monkeypatch.delenv("REX_SERVER")
71
+ rex_env(_clients(4242), "sshd")
72
+ assert _platform._in_rex_remote() is True
73
+
74
+
68
75
  def test_app_over_network_is_remote(rex_env):
69
76
  rex_env(_clients(4242, transport="tcp"), "anything")
70
77
  assert _platform._in_rex_remote() is True
@@ -201,3 +208,22 @@ def test_window_browser_plans_explicit_browser():
201
208
  facts,
202
209
  )
203
210
  assert "explicit_browser" in plan.reasons
211
+
212
+
213
+ def test_mac_helper_reuses_the_apps_tunnel(tmp_path):
214
+ from arrayview import _rex
215
+
216
+ sock = tmp_path / "Application Support" / "abc.sock"
217
+ sock.parent.mkdir()
218
+ sock.write_text("")
219
+ ps = (
220
+ " 4732 90382 /Apps/Rex Server.app/Contents/MacOS/rex __internal ssh-tunnel ssh://gpu\n"
221
+ f" 4733 4732 /usr/bin/ssh -N -T -o ControlPath=none -L {sock}:/run/user/1/rex/server.sock -- ssh://gpu\n"
222
+ # A tunnel of some other rex command, and one to another host.
223
+ f" 4850 4849 /usr/bin/ssh -N -T -L {tmp_path}/other.sock:/run/user/1/rex/server.sock -- ssh://gpu\n"
224
+ " 5000 90382 /Apps/Rex Server.app/Contents/MacOS/rex __internal ssh-tunnel ssh://other\n"
225
+ )
226
+ address = _rex._app_tunnel_address("ssh://gpu", ps)
227
+ assert address == "unix://" + str(sock).replace(" ", "%20")
228
+ assert _rex._app_tunnel_address("ssh://other", ps) is None
229
+ assert _rex._app_tunnel_address("ssh://missing", ps) is None
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes