Repository navigation
ariglx: matplotlib figures as Ariadne windows, and display() (C1) - #1198
Merged
Merged
Conversation
#1159 (O7c) kept the last source sea_surface found in a thread_local, so the velocity a fluid field reads after a cell's height at the same point and time did not invert the sideways move again. A thread_local that keeps state between calls is a static cache, which libcvc's no-singletons rule forbids (VOLROVER-LIBRARY-PORTS-ROADMAP.md 1.3, tools/singleton_scan). #1159's release-grpc job, where the scan runs, was cancelled, so the scan never judged it; the next PR that merges master would fail that lane on it. The memo now belongs to the caller: - sea_surface::source_memo, and height() / velocity() overloads that take one. The plain reads share nothing. - fluid_surface::height_with / velocity_with and a surface_memo the caller owns; the defaults ignore it. ocean_surface passes it to the sea. - field_set::apply keeps one memo per cell, for the cell's height and its velocity at the same clipped centre. The memo is keyed on the point, the time and the digest as before, so every value is unchanged.
The first part of roadmap C1 (ARIADNE_SCRIPTING_HOSTS.md §4.6), in Python, .ari and CMake only, with no C++ change. pycvc_gl.ariadne_mpl is a matplotlib backend, module://pycvc_gl.ariadne_mpl (pycvc_gl.ariadne is a module, so the roadmap's pycvc_gl.ariadne.mpl can't import): - the canvas is Agg's, and each draw publishes a copy of buffer_rgba() with Host.publish_image as the picture figure-<num>; - plt.show() opens each figure in a window. A program with no document of its own gets the shipped pycvc_gl/figures.ari (one window per figure, a Figures menu), and a blocking plt.show() runs the host's loop until those windows are closed. Closing a window closes its figure, with a close_event, as a GUI window does; - plt.show() during a load, from a function the document calls, in a frame or off the main thread neither blocks nor loads a document. There the document's own image: shows the figure by name, or by the name bind(fig, name) gives it, with no window; - draw_idle() coalesces into one draw in the host's next frame, and timers tick on the frames, so FuncAnimation runs; - plt.ion() shows a figure as it is made; - a plain python program with a Host of its own calls attach(host). pycvc_gl.ariadne_display.display(obj) shows an object's richest form, as IPython's display() does: matplotlib figures, numpy pictures and PIL images as pixels, image/png and image/jpeg bundles decoded with PIL, and markdown, LaTeX or plain text as text. display_id and the handle's update() replace an output in place. With no host it prints text/plain. It shares figures.ari's windows (Figures, one per Host, kept on the Host) and imports matplotlib only for a figure. pycvc_gl.ariadne.display forwards to it. The engine (ariadne_python.py): - a one-shot meta_path finder makes the backend matplotlib's default on its first import when a GL host has lent its window and nothing chose a backend (MPLBACKEND, a matplotlibrc). It sets rcParams, never os.environ. arix, ariglx --terminal and <host> python keep matplotlib's own default; - load_document counts the python: blocks it runs (loading), so the backend can tell a load is under way; - display is predefined in a python: block's source, beside export. ci.yml's pycvc-linux installs matplotlib-cp312, so its new tests run rather than skip there. Interaction (wheel, pan, zoom, keys, the cursor) is C2. arix, the browser (W5) and VTK or mesh display() come later. Tests: pycvc_gl_ariadne_mpl (new: a headless Host; draws, windows, user-closed windows, titles, bind, timers, FuncAnimation, blocking show, calls from frames and threads, display); ariglx_matplotlib_show and ariglx_matplotlib_block (new: the default backend, a blocking plt.show() through figures.ari, a python: block's figure shown by the document's own image:); pycvc_gl_ariadne_host, pycvc_gl_ariadne_gil, pycvc_gl_smoke, pycvc_ari, ariglx_python_*, arix_python_* rerun.
The review of C1's first part, fixed. No loop inside the loop. A plt.show() from a document's function that has a top level of its own (exec(), runpy, a script-style import) got past program_level(), and host.run() started a second after_load() inside the frame: in run mode its locals went while the outer loop still called them. Now: - the engine keeps on the app (app.slot, PythonActivity) whether a python: block is loading and whether the host's loop runs, and the thread that attached it. _arihost.run() refuses while the loop runs, during a load, from another thread, or from inside a frame (HostHandles::in_frame, AriRuntime::in_frame()), before it marks the loop as run. Engine::run_loop() runs a host's own loops, the document's too, so ariglx and arix mark every after_load(); - ariglx's after_load takes its input pump and warning listener back when the loop ends, however it ends; - program_owns(host) gates a blocking plt.show(), plt.pause() and figures.ari's load: the program's own code, on the host's thread, outside a frame and a load, and not a document the scripting host loaded. mainloop returns on any of _arihost.run's refusals. No process-wide state. ariadne_python.py's loading counter is gone (_arihost.loading() reads the app's), and so is ariadne_display's module-wide attached Host: a figure carries its Host. attach(host) gives it pyplot's open figures (and the ones pyplot makes while one of them is current), show_in(host) attaches and shows, and display() takes host=. A process-wide default host, which pyplot's own figures would want, is left for a decision. pycvc_gl.ariadne_mpl: - a blocking plt.show() blocks only where a window can be closed: a plain Host in a window (until figures.ari shows nothing, so a later plt.show() shows again), or the scripting host's loop, which ends once (a later blocking one warns). On an offscreen or headless Host it returns at once, as Agg's does; - plt.pause() runs the host's frames for its interval (start_event_loop), where the program runs them. pycvc_gl.ariadne_display: - a timer's tick, a deferred draw or a close_event handler that raises is printed (as matplotlib's GUI backends print one), and the frame goes on: the other canvases draw, and figures.ari's close check runs; - display() to a closed host, or one its scripting host let go, prints; - figures.ari's windows are ari_figure_<k>, so no document's own id is taken, and a document of the host's own gets none: display() prints its text/plain form there, and a figure shows through the document's image:. Only an embedded host's figures.ari closes itself; - the scripting host is adopted only where it has lent a GL window, and pycvc_gl.ariadne never adopts arisrvx's (mode server). The display() predefined in a python: block prints where no GL window is lent (arix, ariglx --terminal, arisrvx) instead of reaching for a host. Tests: ariglx_matplotlib_nested (new: exec() and runpy plt.show() from a document function in a frame return with no frame run, host.run() is refused, and the frames go on; it also ends under ariglx run); ariglx_matplotlib_close (new: the last window closing ends the scripting host's loop well before the snapshot's 60 frames); arix_matplotlib_backend (new: arix keeps matplotlib's own default); ariglx_matplotlib_show (host.run() from a frame of the program's own is refused and leaves the loop to run); ariglx_matplotlib_block (no frame runs during the load; the block's own display() prints); pycvc_gl_ariadne_mpl (per-figure hosts, two Hosts, failing timers and draws, a headless show returns, a window show blocks twice, plt.pause, display() with no window); pycvc_gl_ariadne_host, pycvc_gl_ariadne_gil, pycvc_gl_smoke, pycvc_ari, pycvc_ariadne*, ariglx_python_*, arix_python_*, ari_python_needs_arix rerun. The browser build compiles the touched sources.
Whitespace only: the changed-lines check wanted the conditional chain laid out as clang-format 18 does.
…ata scan passes
transfix
enabled auto-merge (squash)
November 13, 2026 03:54
transfix
added a commit
that referenced
this pull request
Nov 13, 2026
transfix
added a commit
that referenced
this pull request
Nov 13, 2026
transfix
added a commit
that referenced
this pull request
Nov 13, 2026
transfix
added a commit
that referenced
this pull request
Nov 13, 2026
#1198 edited bindings/pycvc/pymod_gl/ariadne.py, which this branch moves to bindings/pycvc/pymod/ari.py (pycvc.ari), leaving an alias behind. The alias stays as it was, and #1198's two hunks move to ari.py: - _arihost() never adopts arisrvx's host (mode "server"). - display(obj, **kwargs) imports pycvc_gl.ariadne_display by its full name, because a relative import does not resolve from pycvc.ari. pycvc_gl.ariadne.display is the same function, through the alias.
transfix
added a commit
that referenced
this pull request
Nov 13, 2026
The one conflict was arigl_web_smoke.mjs. Both sides are kept: - the /apps/up endpoint, with #1200's ISOLATION headers on its replies as on every response; - the settle probe reads out and isolated/sab; - each case runs its before/inject and #1200's isolation check. The headless-Chrome smoke passes 6/6 here, the picked-file upload included. Master since then: #1179, #1174, #1196, #1198, #1178, #1157, #1172, #1200.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first part of roadmap C1: matplotlib in the
xhosts (docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md§4.6; §10's C1 row and §4.6's "as built" note are updated). Nativeariglxfirst.What it adds
pycvc_gl.ariadne_mpl, a matplotlib backend (module://pycvc_gl.ariadne_mpl;pycvc_gl.ariadneis a module, so the roadmap'spycvc_gl.ariadne.mplcan't be imported):buffer_rgba()withHost.publish_imageas the picturefigure-<num>.plt.show()opens each figure in a window. A program with no document of its own gets the shippedpycvc_gl/figures.ari(one window per figure, a Figures menu). A blockingplt.show()runs the host's loop until those windows are closed. Closing a window closes its figure and firesclose_event, as a GUI window does.plt.show()during a load, from a function the document calls, inside a frame or from another thread doesn't block and doesn't load a document. In those cases the document's ownimage:shows the figure by name, or by the namebind(fig, name)gives it.draw_idle()coalesces into one draw in the host's next frame. Timers andplt.pause()run on the frames, soFuncAnimationworks.plt.ion()shows a figure as soon as it is made.plt.show()blocks only where a window can be closed. On an offscreen or headless Host it returns at once, as Agg's does.pycvc_gl.ariadne_display.display(obj)shows an object's richest form, as IPython'sdisplay()does:image/pngandimage/jpegbundles, decoded with PIL;display_idand the handle'supdate()replace an output in place. With no GL window (arix,ariglx --terminal,arisrvx, a document of its own) it printstext/plain.displayis predefined in apython:block, besideexport.Engine (
ariadne_python.py,python_engine.cpp):meta_pathfinder makes the backend matplotlib's default on its first import, when a GL host has lent its window and nothing else chose a backend. It setsrcParamsand never touchesos.environ.arix,ariglx --terminaland<host> pythonkeep matplotlib's own default.app.slot<PythonActivity>, whether apython:block is loading, whether the host's loop is running, and which thread attached the engine._arihost.run()refuses in four cases: while the loop runs, during a load, from another thread, and from inside a frame (HostHandles::in_frame,AriRuntime::in_frame()).Engine::run_loop()marks everyafter_load().ci.yml's pycvc-linux job now installsmatplotlib-cp312, so the new tests run there instead of being skipped. The writable-data allowlist is unchanged.How it was tested (Windows, shared Release build: libcvc, cvcGL, ari/arix, arigl/ariglx, pycvc, pycvc_gl; cvcpkg python312 + numpy + matplotlib in its own prefix)
pycvc_gl_ariadne_mpl: passed (90 checks, matplotlib 3.10.0)ariglx_matplotlib_show/_close/_block/_nested: 4 passedarix_matplotlib_backend: passedariglx_python_check,ariglx_python_program: 2 passedarix_python_block,arix_python_program,arix_python_error,arix_python_interpreter: 4 passedari_python_needs_arix: passed (after buildingari)pycvc_ariadne,pycvc_ariadne_server,pycvc_gl_smoke,pycvc_ari,pycvc_gl_ariadne_host,pycvc_gl_ariadne_gil: 6 passedariglx run mpl_nested.ariin a real window: no crash, frames kept running, EXIT=0mpl_blockwith the Python ownership check forced to true: the C++ load refusal held, frame_count 0, exit 0_arihost.run's refusal chain with clang-format 18.1.8, which the changed-lines check needs. After it,arixandariglxwere rebuilt and the 12 arix/ariglx python and matplotlib tests pluspycvc_gl_ariadne_mplpassed again.git-clang-format --diffagainst the merge base reports no changes.Left out
arisrvxwas not built or tested in this tree (CVC_BUILD_ARISRV=OFF). Its engine path changed slightly: attach now records the host thread on the app, and the server-mode guards were added.pycvc_ariadne_serverpassed under plain python.display()prints, and figures show through the document's ownimage:.display()come later.Merging waits on Joe's review.