Sample Internals#
This page of the Technical Guide is for maintainers who change a sample. It
covers how the sample code is organized, how the SDK archive and the
wheel package it, and how the test_samples target checks it.
The Architecture glossary defines the implementation terms, and
Concepts the consumer vocabulary.
The user documentation of the samples lives on other pages. Link to them instead of repeating their content here:
Topic |
Canonical page |
|---|---|
Which sample teaches which API, where each one lives in the wheel and the SDK archive, and how the packaged launchers select a runtime |
|
One sample’s prerequisites, commands, options, expected output and code walkthrough |
The sample’s |
The |
|
Building the C++ samples against an SDK archive |
Building the C++ samples in the C/C++ quickstart |
How the launchers find an install tree in a source checkout |
Sample launchers in a source checkout in Local Development |
Sample map#
Sample |
Programs |
API |
Packaged in |
Checked by |
|---|---|---|---|---|
|
|
The canonical C ABI, |
SDK archive: both programs. Wheel: the Python program. |
|
|
|
The Suite: |
SDK archive: both programs. Wheel: the Python program and |
|
|
|
The Suite’s support for the legacy |
SDK archive: both programs. Wheel: the Python program. |
|
|
A Python package; the entry point is |
Neither package |
|
Each sample folder has a README.md.
Shared files in samples/:
build_samples.shandbuild_samples.batconfigure and build every first-level sample directory that has aCMakeLists.txt.windows_argv.batforwards an argument vector, passed in environment variables, to a child process without a second cmd parse. Therun_*.batlaunchers of the three product samples use it, so that checkout paths and arguments with& | < > ^ ! %survive.sdk_runtime.pyprints the loader directories of the external ovstage runtime that an ovstage SDK archive declares. The C++ launchers run it before they start the executable.
The packages add two generated entries: samples/data/, which holds the fixtures listed in
scripts/sample_data_files.cmake (time_sampled.usda), and samples/ovclash_backend.txt, which
names the packaged backend
(Backend markers).
Suite API processor#
samples/clash_suite_api is the reference processor for the Suite API. Each process runs one
query, saves it to a SQLite store (--clashdb) or a directory store (--clashdir), and exports
JSON (--json) and HTML (--html). It mirrors the Kit
extension omni.physx.clashdetection.examples. Both programs take the same command line.
Symbol |
File |
Role |
|---|---|---|
|
|
The settings of one run. |
|
|
Opens the stores, runs detection, fetches and saves the results, and exports them. |
|
|
The same flow through |
|
|
Owners that destroy the Suite runtime and data handles on scope exit. |
Rules to keep:
The processors default to asynchronous detection and asynchronous fetch-and-save (
async_mode = TrueinClashProcessorConfig,asyncMode = trueinProcessorConfig).--async falseruns both phases on the calling thread.That default belongs to the sample. The library’s
ClashDetection.fetch_and_save_overlaps()stays synchronous by default (async_mode=False).run_custom_clash.shandrun_custom_clash.batrun only the Python processor, and take its options without--.samples/clash_suite_api/clash_processor.mddocuments them for users, including the order in which they pick a runtime. Keep that guide, the processor’s--helpand the two launchers in step.
Canonical clash API#
samples/clash_api stays on the canonical C ABI. It has no query records, no persistence and
no HTML export. It opens a stage, applies run settings and an A/B
scope, runs the pipeline step by step or with --async, and
prints the overlaps, the overlap reports, the query statistics
and the duplicate meshes. --json PATH writes a plain summary.
Symbol |
File |
Role |
|---|---|---|
|
|
Parses the options and runs everything inside one |
|
|
Runs the pipeline step by step, or polls an asynchronous run. |
|
|
The same calls through |
|
|
Maps the options to |
Rules to keep:
These programs default to single-threaded runs. The library and
python -m ovclashdefault to multithreading.They build an overlap report only for the first 16 overlaps (
_MAX_OVERLAP_REPORTS).
Legacy clash detection#
samples/legacy_clash_detection opens or creates a legacy .clashDetection container through the
Suite. It writes a .clashDetection copy and a normal .ovclashdb SQLite store with save_as.
Symbol |
File |
Role |
|---|---|---|
|
|
Prepares or probes the input, opens it, lists its queries and writes both outputs. |
|
|
The same flow through |
|
both programs |
Create the missing input, with one query named |
Rules to keep:
The launchers take no
--backend. In a packaged SDK archive or wheel they use that package’s runtime. In a source checkout they fall back to_build/install/openusd.test_samples.cmakecannot drive these launchers throughtest_single_sample.cmake, so the sample has its own task; see How the samples are tested.
How the samples are packaged#
Package |
Which samples |
What it leaves out |
|---|---|---|
SDK install tree and SDK archive |
Every |
The other platform’s launchers, |
Python wheel |
The explicit list in |
The same files, plus every native development file. |
Packaging details:
Both packages ship only the build platform’s launchers, and both ship
samples/sample_python.py, the runtime helper of the packaged launchers. The SDK archive also shipsbuild_samplesand, on Windows,windows_argv.bat, the build-root helpersample_build_root.batand the two toolchain helpers. The wheel ships no C++ sample tooling; on Windows it keeps onlywindows_argv.bat, for its Python.batlaunchers. Release verification rejects an SDK archive withoutsample_python.py, or a Windows SDK archive withoutsample_build_root.bat.scripts/prepare_python_wheel.pyprunes the wheel staging copy withnative_development_members()fromscripts/verify_release_artifact.py. Undersamples/, that rule matches C and C++ sources,CMakeLists.txt,build_samples.*,run_*_cpp.*and.exefiles. Release verification rejects a wheel that still holds one.scripts/test_python_wheel.cmakerequiressamples/ovclash_backend.txt,samples/sample_python.py, the threerun_*_pythonlaunchers of the platform, the fixtures and, on Windows,windows_argv.bat.The install step uses
USE_SOURCE_PERMISSIONS, so therun_*.shlaunchers keep their execute bit.
How the samples are tested#
The test_samples CMake target checks the three product samples for the build tree’s backend,
against its install tree. scripts/test_samples.cmake writes a task list to
<validation-dir>/test_samples_tasks.json and runs it through scripts/run_parallel.py.
<validation-dir> is _build/validation/<backend>/<generator>/<configuration>.
Task |
Script |
What it checks |
|---|---|---|
|
|
Runs the launcher with |
|
|
The same launcher run and output check, on the JSON export rows, the HTML file and the |
|
|
A run without outputs, a run with outputs, the pick-up of the local |
|
|
A launcher run that creates the missing input. |
How the tasks run:
test_samples.cmakefinds launchers with the globsamples/*/run_*<suffix>. It takes the language from the last_token of the file name:run_clash_api_pythongivespython. It skipsclash_suite_apiandlegacy_clash_detection, which have their own tasks. It also skipsovrtx_clash_sample_app, which has its own target.Each launcher run writes to
<validation-dir>/sample_validation/<sample>_<language>_<backend>. The full log of every task goes to<validation-dir>/run_parallel_logs/test_samples. The console shows one start line and one verdict per task, and the full output of a failed task.The tasks run in parallel only when
OVCLASH_PARALLEL_TESTSis on.test_samples.cmakereads it only from-D; see Parallel tests and shard planning.On ovstage, a launcher run fails when its output contains
RegisterBehaviorForPrimTypeId, a duplicate UsdShade registration diagnostic.
--validate runs test_samples with the other validation steps. To run only the sample checks
for one backend, run the backend’s build wrapper from ovclash/ with --target test_samples. The
target depends on install_sdk, so the wrapper builds and installs first; use the build type of
the install tree you want checked.
Linux:
./build_ovstage.sh --release --target test_samples
Windows:
build_ovstage.bat --release --target test_samples
A passing run ends with ovclash sample correctness tests passed for ovstage. A failing run stops
with ovclash sample correctness tests failed for ovstage, after the console has shown the full
output of each failed task; the logs are under <validation-dir>/run_parallel_logs/test_samples.
The expected results#
scripts/check_sample_outputs.py holds EXPECTED: one table per backend, with the five cases
static, dynamic, duplicates, point_cloud and dynamic_point_cloud. _case() builds each
case from these keyword arguments and derives overlap_count, duplicate_count and
duplicate_order from them:
Field |
Type |
Required |
Default or values |
Description |
|---|---|---|---|---|
|
|
Yes |
Keys |
The expected query statistics |
|
|
Yes |
One dictionary per overlap, such as |
The expected |
|
|
No |
|
The expected duplicate summaries, in order |
|
|
Yes |
One list of cell texts per row |
The expected |
|
|
No |
|
How many export rows name a |
For
clash_api, it checks each summary’s backend, overlap and duplicate counts and full statistics. It matches overlaps byclash_idand compares names, type, mesh CRCs, element and record counts and the report sizes exactly. Time, distance, depth and point size may differ by at most2e-4. Duplicates must also keep their order.For
clash_suite_api, it compares the full JSON export columns and rows. It checks that the HTML file names the first two clash IDs and that the.ovclashdbfile is not empty.For every pair, it recomputes the public clash ID from the two prim paths.
Any other
--samplename prints a skip message and passes.
The two backend tables hold the same overlaps, duplicates, statistics and Suite rows. Only the
point-cloud reports differ: ovstage reports point_size0 0.05 for
/Root/Points/telephone_booth_widths_per_point, where OpenUSD
reports 0.0. This is the “Uniform
per-point widths” row of What the backend changes.
To reproduce one check by hand, run the launcher for one backend into a scratch directory, then
run the checker with the same backend. The checker needs only the Python standard library. In a
source checkout, the launcher uses _build/install/<backend> unless --install-root names another
tree. From ovclash/:
Linux:
samples/clash_api/run_clash_api_python.sh --backend ovstage --output-dir _build/sample-check
python3 scripts/check_sample_outputs.py --sample clash_api --backend ovstage --output-dir _build/sample-check
Windows:
samples\clash_api\run_clash_api_python.bat --backend ovstage --output-dir _build\sample-check
python scripts\check_sample_outputs.py --sample clash_api --backend ovstage --output-dir _build\sample-check
A passing check prints one line (on Windows with backslashes in the path):
Validated clash_api ovstage outputs in _build/sample-check
A failing check stops at the first difference with an AssertionError. For example, outputs of
the ovstage backend checked with --backend openusd report:
AssertionError: clash_api openusd static backend: expected 'openusd', got 'ovstage'
When you change a sample:
If its results change, update
EXPECTEDfor both backends. Keep the tables identical except for documented backend differences.Name a new launcher
run_<sample>_<language>.shor.bat. The glob andtest_single_sample.cmakedepend on that name. A launcher thattest_single_sample.cmakedrives must accept--config,--backend,--install-rootand--output-dir.Add a new product sample to the wheel list in
scripts/build_wheel.cmakeand to the required wheel members inscripts/test_python_wheel.cmake. The install tree picks it up through itsCMakeLists.txt.List every fixture that a launcher opens as
../data/<name>inscripts/sample_data_files.cmake. A sample README names such a fixture as../data/<name>, because no package containstests/data.Commit
run_*.shlaunchers with mode 755.test_sample_launchers_ship_executableintests/python_tests/test_build_script_contracts.pychecks it.
ovRTX clash sample app#
samples/ovrtx_clash_sample_app is a developer viewer that renders a stage with ovRTX and
runs queries through ovclash_suite; it is not part of the product surface, and neither package
contains it. ovRTX clash sample app covers its internals, and its own
samples/ovrtx_clash_sample_app/README.md documents its use.