Repository navigation
pycvc_gl.ariadne: a Python host for Ariadne documents - #985
Merged
Merged
Conversation
Host functions with arguments and a value (AppRuntime::register_function / register_async_function; pycvc.host_function from Python), a GL-free host (pycvc.AriApp), and pycvc_gl.ariadne.Host over AriRuntime or AriApp: data in (values, trees, tables, series, pictures, streams), data out (get, watch, frames), and the document's calls into Python. The GIL: AriRuntime's frame/render/step/run/load/wait_idle and its destructor, AriApp's, and cvc::app's destructor release it, so an async Python function finishes while frames run, under run(), and at teardown (del app with a call in flight deadlocked). A frame entered from inside one raises. Examples (hello, data_feed, form, nav) in examples/ariadne/python, tests pycvc_ariadne, pycvc_gl_ariadne_host and pycvc_gl_ariadne_gil, and docs/ARIADNE.md 9.3 Writing a Python host.
…t-function C++ tests examples/ariadne/python/nav.py drives Humvees on a sim_world through Austin when its bundle is installed (a block city otherwise): true-scale models, routes planned for their turning radius, Jolt or kinematic plant, chase or overview camera, map picture, terrain_lab's soft afternoon look. pycvc.nav_world_rasterize (cvc::nav::rasterize, no VTK), nav_plant(ground=field), pycvc_gl.scenes.find_scene / find_vehicle_model, pycvc_gl.vehicle.VehicleModel / seat_transform / body_transform. AriadneHostVerbs tests for register_function and register_async_function.
The terrain's height at each grid sample (nav_world_rasterize) goes to the navigator with the Humvee's terrain_config_of (nav_sim_world_set_terrain), and the routes keep off the slopes nav_terrain_build marks infeasible. On Austin's relief (--relief) that halves the Jolt rollovers (8 -> 4 of 16 in 96 s); the rest are cornering on 10-25 degree side slopes at 5-9 m/s, which the climb limit does not cover, so flat-ground physics stays the default.
…res:) AriadneComponents.ShippedExamplesDeclareWhatTheyNeed failed on every CI platform: python/data_feed.ari and python/nav.ari had no requires: block, and nav.ari has a scene: without requiring gl.scene. data_feed.ari requires quit, with stream_view and raster.bitmap optional (a headless run shows text). nav.ari requires gl.scene and quit, so, like every shipped document with a scene, a host without a scene refuses it: nav.py --headless now says so instead of running, and its headless branches are gone. The host test's nav runs (kinematic and Jolt) move to the offscreen section, which CI runs on llvmpipe under Xvfb, and the headless section checks the refusal.
This was referenced Nov 3, 2026
transfix
added a commit
that referenced
this pull request
Nov 3, 2026
* docs: roadmap for Ariadne scripting hosts (ari-py, arigl-py, arisrv-py) Host variants that embed CPython with pycvc, pycvc_gl and numpy, natively and in one wasm module: what already exists (static CPython/numpy/vtk-python/pycvc_gl for wasm, the Python host in #985, VolRover3's embedded interpreter), the naming, the engine and host module, a python: block for documents with a trust rule, the arigl-py-web link and its risks, server documents and sandboxed client scripts on arisrv (RestrictedPython in worker processes), and where Lua fits later. Design only; nothing is built. * docs: name the scripting hosts arix, ariglx, arisrvx and ariglx-web The x marks the extended host (the stock runtime plus its scripting engines), so a Lua engine can join the same binaries without the names going stale. Lua's hosting now lands in the x hosts beside Python; the stock hosts stay a separate decision.
This was referenced Nov 3, 2026
…OS CI) AnAsyncFunctionTakesArgumentsAndPostsToItsChannel failed on package-macos / libcvc-release: the call's wait is charged to the action (ariadne.limits.action_max_time, 0.1 s by default), and on the loaded macOS runner starting the kernel and its 20 ms took longer, so the program was stopped (time_limit_exceeded) before it set got or posted to the channel. Reproduced here with the cap set to 0.5 ms (the same failure, and run_program's done says time_limit_exceeded). The test is about the arguments and the channel, so it sets the cap a host gives (30 s) and checks the program finished.
…ne-host # Conflicts: # src/cvcGL/ariadne/AriRuntime.cpp
* Ariadne: arix and ariglx, ari and arigl with an embedded Python The first part of the scripting hosts (docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md, P1), native: - src/ariadne_python: the engine. One CPython per process, booted from the install prefix's python312 (else the Python built against), the GIL parked between crossings. The _arihost builtin lends Python the host's app, document runtime and (ariglx) window objects. - A document's python: block runs at load, before requires: is checked; its @export functions (and export: entries) become host functions through pycvc.host_function. The python and python.<module> capability tokens hold there; a stock host names the scripting hosts instead. - A Python program in place of the document (arix|ariglx run|snapshot|check app.py): pycvc_gl.ariadne.Host() adopts the host (mode "embedded"), and host.run() runs the host's own loop. <host> python [args] is the embedded interpreter as a plain python3. --python-path DIR. - AppRuntime::add_load_hook and add_frame_hook; pycvc.ari_app_attach; pycvc_gl's *_from_capsule proxies over a host's window objects. - ctest: arix_python_* (block, program, error, interpreter), ari_python_needs_arix, ariglx_python_check / _program; three AriadneRequires cases. pycvc-linux builds and runs them. * cvcpkg: arix and ariglx recipes, published from the cp312 Linux job The scripting hosts as cvcpkg packages of their own, so ari and arigl stay Python-free. Each recipe builds src/ari or src/arigl standalone with -DARI_WITH_PYTHON / -DARIGL_WITH_PYTHON against the installed SDKs and the deps prefix's python312 (named outright, not a system python3), and installs only its own binary. Runtime deps bring python312, numpy-cp312, pycvc-cp312 (and for ariglx pycvc-gl-cp312) into the same prefix, where the installed host finds its Python beside it. Linux only, where pycvc-cp312 and pycvc-gl-cp312 are published. A recipe build no longer compiles in the build's Python home (CVC_ARIADNE_PYTHON_HOME is in-tree only), so no builder path ships. publish-cvcpkg.yml builds, smoke-tests, packs and publishes both in the cp312 job: arix runs `arix python` and the python: block test document through that job's pycvc; ariglx, last, loads it and renders the Python program's document under Xvfb. * publish-cvcpkg: PYTHONHOME for arix and ariglx alone, not the cvcpkg that packs them The dry run (41598099932) built both and both passed their smoke tests on Linux (arix: its interpreter and python_block.ari 5/5; ariglx: the python: block in a window and app.py rendered), then cvcpkg pack died with "No module named 'cvcpkg'": the exported PYTHONHOME pointed cvcpkg's own Python at $PY's stdlib. The hosts now get it through env, one command at a time.
… feat/pycvc-gl-ariadne-host
…ne-host # Conflicts: # .github/workflows/publish-cvcpkg.yml # bindings/pycvc/pycvc_physics.i # src/ari/main.cpp # src/arigl/main.cpp
transfix
added a commit
that referenced
this pull request
Nov 5, 2026
This was referenced Nov 6, 2026
transfix
added a commit
that referenced
this pull request
Nov 6, 2026
…1028) * docs: scripting-hosts roadmap says what P1 shipped (#985, v3.7.11) The roadmap predates P1. It now describes what #985 shipped and marks what didn't: - 3.1: the engine is src/ariadne_python, compiled into each x host by cvc_ariadne_python_host (ARI_WITH_PYTHON / ARIGL_WITH_PYTHON, or CVC_BUILD_PYCVC in-tree), not a cvc_ari_python library; Engine's real config and home rules; _arihost's functions; no py-eval / py-exec and no script_engine interface yet (the token registry and the load and frame hooks are P1's seams). - 3.2: an explicit mode inside an x host opens a separate Host rather than raising; run()'s two forms. - 4.1-4.5: python.<module> is the one module token (python.vtkmodules, not python.vtk); ari info lists tokens; the block runs on every load, before requires:; its keys and export forms; caps raised for every document; load:ed modules' blocks, --python-allow and run -m are planned (P1b); the console is P2. - 9, 10: risks 4 and 6 updated; P0 and P1 done, the rest of P1 is a new P1b row, which L1 and G1 now need for the script_engine interface. * docs: scripting-hosts roadmap review fixes (configure error, arix's closure, find_spec) - An explicit -DARI_WITH_PYTHON=ON / -DARIGL_WITH_PYTHON=ON makes a missing Python Development.Embed a configure error; only in-tree is the target skipped. - arix links libcvc and libpython only, and a Python program under arix needs pycvc-gl-cp312 for Host; ariglx links libcvcGL too. - python.<module>: find_spec imports a dotted module's parent package.
transfix
added a commit
that referenced
this pull request
Nov 6, 2026
…1026) New section 6.5 covers what a service such as cy-pca/cyprov needs from one arisrvx process: - an asyncio loop on the script thread; - serve_asgi for FastAPI/uvicorn, with lifespan and graceful shutdown; - server-published namespaces; - an authenticate hook that yields principals, and per-principal read scopes; - room-call with ctx (principal, progress, idempotency, deadline), role gates and CallError; - a relay join mode for ari and the x hosts, plus native transport security; - a ServerHarness for plain-python tests. Phases S0-S2 gain these parts, S5-S7 are new, and the application-services cut S0-S2 + S5 + S7 is called out. Risks 16-19 are new. The status line now records that P0/P1 landed in #985.
This was referenced Nov 9, 2026
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
…_gl (#1216) A Python program run in place of the document (arix run app.py) adopts the host with Host(), which lived in pycvc_gl.ariadne (#985). Under arix the Host never draws: with no GL it drives the host's own runtime through core pycvc (pycvc.ari_app_attach), as a headless Host drives pycvc.AriApp. But the import ran pycvc_gl's __init__, which loads the native _pycvc_gl (cvcGL and VTK). So the arix recipe told programs to install pycvc-gl-cp312 beside it, and ctest arix_python_program failed in any tree built without pycvc_gl. The module moves to core pycvc as pycvc.ari (bindings/pycvc/pymod/ari.py). It is installed beside pycvc.py as _pycvc_ari.py, the way pycvc.ariadne is. pycvc.ariadne stays arisrvx's server Host. - pycvc imports it as pycvc.ari. pycvc-cp312's `_pycvc*` files already cover it. - A window or offscreen Host, host.lab, and an embedded Host in ariglx import pycvc_gl when they need it. If it is missing, the ImportError says to install pycvc-gl-cp312 or use mode="headless". - pycvc_gl.ariadne is the same module, not a copy. Importing it puts pycvc.ari in its place, so `pycvc_gl.ariadne is pycvc.ari`, and existing imports get the same Host, current_host() and export. - The browser's python312.zip and the pycvc-gl wasm host (link-host.sh) ship _pycvc_ari.py beside pycvc.py, since pycvc_gl.ariadne needs it. - The arix test program, the examples, ari's and ariglx's help, the recipes and ARIADNE.md 9.3 and 9.6 name pycvc.ari. The logger is pycvc.ari. Tests: - pycvc_ariadne runs a document under a headless pycvc.ari.Host and checks pycvc_gl is never imported. - pycvc_gl_ariadne_host checks the alias. - arix_python_program passes with CVC_BUILD_PYCVC_GL=OFF.
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.
A Python program can now host an Ariadne document: open it (in a window, offscreen, or headless with no GL), have the document call Python functions with arguments and get values back, push values, tables, series, pictures and streams into it, and read back what it produces.
pycvc_gl.ariadne.Hostis the API; four examples inexamples/ariadne/pythonshow it to the Python team;docs/ARIADNE.md§9.3 is now "Writing a Python host".What it adds
C++
AppRuntime::register_function(name, native_fn)andregister_async_function(name, marshal, done_channel): host functions with arguments and a value. The oldregister_verb/register_async_verbtook none and returned a string. AlsoAppRuntime::run_program(script, done).AriRuntimeforwards those and addspublish_image,enable_streaming(the stream verbs andstream_view),prefix,has_function,register_quit/exit_codeandwait_idle.frame(),render(),step()andrun()throwstd::logic_errorwhen called from inside a frame (from a handler or a function the frame is running).pycvc
pycvc.host_function(name, fn, is_async=False, with_call=False, done_channel="")builds a host function from a Python callable. It is built in pycvc, where the value conversion lives, andpycvc_gltakes it through SWIG's type table.pycvc.AriApp: a GL-free host, anAppRuntimewith no backend and no scene, for tests and CI.pycvc.nav_world_rasterize(world, rows, cols, bounds, inflate): cvc::nav's planning grid (occupancy and terrain height) from a city bundle's world, with no VTK.pycvc.nav_plant(..., ground=field): on terrain that isn't flat, each vehicle starts on the ground under it (nav_plant_options::ground_height). Before, every vehicle started atground_z, inside raised terrain.pycvc_gl
pycvc_gl.ariadne.Host:window/offscreen/headless;on,function,async_function,on_frame,watch,emit;set/set_tree/set_table/set_series/publish_image/open_stream/run_program;get*/get_tree/get_series/snapshot/frame_rgb;run,step,settleandclose;host.labover the document's scene, plusframe_bounds.pycvc_gl.scenes.find_scene/find_vehicle_modelfind the installed scene bundle and vehicle model.pycvc_gl.vehicle.VehicleModelmakes a glTF vehicle +X-forward and +Z-up at true scale, as the C++ demos'load_vehicle_templatedoes.seat_transformandbody_transformplace it.The GIL, both ways
AriRuntime'sframe/render/step/run/load/wait_idleand its destructor;AriApp's;cvc::app's destructor.run()held the GIL, so an async Python function waited for it forever.del appwith a Python call in flight deadlocked: reproduced (no exit in 30 s), now done in 0.5 s.~appwaits for the app's async calls.step()/run()from a callback raisesRuntimeError, andload()from one waits for the frame to end.test_pycvc_gl_ariadne_gil.pyruns each case in its own process with a timeout, so a deadlock fails the test instead of hanging it:run()with an async function;close()and dropping everything with a call in flight, headless and GL.Examples (
examples/ariadne/python)hello.pyariadne_hello(greet NAME)in Python, another raises an event Python handles, and Python writes the document every framedata_feed.pyariadne_streamrepeat:), a numpy picture and a live video stream pushed from Python; the document's controls read backform.pynav_computestate-set-tree; an async Monte Carlo runs while the UI keeps drawing; awatchrecomputes a previewnav.pynav_convoy,nav_city_drivesoftness: 3.nav_sim_world_set_terrainwith the Humvee'sterrain_config_of), and routes keep off the slopesnav_terrain_buildmarks infeasible.--reliefputs it on the real terrain and building mesh.requires:(AriadneComponents.ShippedExamplesDeclareWhatTheyNeed).nav.arihas ascene:, so it requiresgl.sceneandnav.pyhas no headless run: it runs in a window or--offscreen.Tests
New:
pycvc_ariadne(29 checks, no GL);pycvc_gl_ariadne_host(46 headless checks, plus 17 offscreen including all four examples, nav on both Jolt and kinematic);pycvc_gl_ariadne_gil(8 cases);nav_world_rasterizeintest_pycvc_world_geometry.py;nav_plant(ground=)intest_pycvc_nav_routes.py;AriadneHostVerbs.AFunctionTakesArgumentsAndReturnsAValueand.AnAsyncFunctionTakesArgumentsAndPostsToItsChannel.Locally, Windows, MSVC 14.44 with the cvcpkg prefixes:
bindings/pycvc/test_pycvc*.pyscripts pass;ariadne_host_test: 44 passed, 11 skipped (no FTXUI here);ariadne_loader_test: 214 passed, 2 skipped ("built without yaml-cpp or json-schema-validator").The GL halves skip without a GL context unless
CVC_REQUIRE_RENDER=1, whichpycvc-linuxsets under Xvfb.Findings
did not complete: time_limit_exceeded). An async call's CPU time counts as steps at 8000 per ms.Hostraises the caps by default (limits=overrides) and the docs say why.reachedturns true, then the agent rolls on past it. nav.py sends each arrival a new route instead.--relief), the grade term halves the rollovers: 8 of 16 Humvees in 96 s without it, 4 with it. The rest roll in open ground on 10-25 degree side slopes at 5-9 m/s. The grade limit is the climb, not cornering on a side slope.pycvc_gl.scenes.terrain_grid, which this tree has retired. Its Ariadne ports PR fixes them.Not done