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

Samples

One sample’s prerequisites, commands, options, expected output and code walkthrough

The sample’s README.md; the sample map names each one

The clash_suite_api processor as a tool: run_custom_clash, its complete command line, output stores and recipes

samples/clash_suite_api/clash_processor.md

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

samples/clash_api/

clash_api_python.py, ClashApi.cpp

The canonical C ABI, <ovclash/ovclash.h>, and its ovclash Python binding

SDK archive: both programs. Wheel: the Python program.

test_samples

samples/clash_suite_api/

clash_suite_api_python.py, ClashSuiteApi.cpp, run_custom_clash.*

The Suite: ovclash_suite and <ovclash_suite/ovclash_suite.h>

SDK archive: both programs. Wheel: the Python program and run_custom_clash.*.

test_samples

samples/legacy_clash_detection/

legacy_clash_detection_python_api.py, LegacyClashDetection.cpp

The Suite’s support for the legacy .clashDetection container

SDK archive: both programs. Wheel: the Python program.

test_samples

samples/ovrtx_clash_sample_app/

A Python package; the entry point is ovrtx_clash_sample_app.py

The Suite, with ovRTX, ovui and ovstage

Neither package

test_ovrtx_sample, test_python_sample_app

Each sample folder has a README.md.

Shared files in samples/:

  • build_samples.sh and build_samples.bat configure and build every first-level sample directory that has a CMakeLists.txt.

  • windows_argv.bat forwards an argument vector, passed in environment variables, to a child process without a second cmd parse. The run_*.bat launchers of the three product samples use it, so that checkout paths and arguments with & | < > ^ ! % survive.

  • sdk_runtime.py prints 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

ClashProcessorConfig

clash_suite_api_python.py

The settings of one run. _config_from_args() builds it from the command line.

ClashProcessor.run()

clash_suite_api_python.py

Opens the stores, runs detection, fetches and saves the results, and exports them.

runProcessor()

ClashSuiteApi.cpp

The same flow through <ovclash_suite/ovclash_suite.h>.

RuntimeHandle, DataHandle

ClashSuiteApi.cpp

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 = True in ClashProcessorConfig, asyncMode = true in ProcessorConfig). --async false runs 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.sh and run_custom_clash.bat run only the Python processor, and take its options without --. samples/clash_suite_api/clash_processor.md documents them for users, including the order in which they pick a runtime. Keep that guide, the processor’s --help and 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

main()

clash_api_python.py

Parses the options and runs everything inside one ClashRuntime.

_run_pipeline()

clash_api_python.py

Runs the pipeline step by step, or polls an asynchronous run.

run()

ClashApi.cpp

The same calls through <ovclash/ovclash.h>.

configureSettings()

ClashApi.cpp

Maps the options to ovclash_settings_t flags and fields.

Rules to keep:

  • These programs default to single-threaded runs. The library and python -m ovclash default 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

read_and_write_legacy_clash_detection()

legacy_clash_detection_python_api.py

Prepares or probes the input, opens it, lists its queries and writes both outputs.

readAndWriteLegacyClashDetection()

LegacyClashDetection.cpp

The same flow through <ovclash_suite/ovclash_suite.h>.

_prepare_input(), prepareInput()

both programs

Create the missing input, with one query named Legacy sample query.

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.cmake cannot drive these launchers through test_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 samples/* directory that has a CMakeLists.txt (a glob in CMakeLists.txt).

The other platform’s launchers, __pycache__, *.pyc, _build and .venv-ovclash.

Python wheel

The explicit list in scripts/build_wheel.cmake: clash_suite_api, clash_api and legacy_clash_detection.

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 ships build_samples and, on Windows, windows_argv.bat, the build-root helper sample_build_root.bat and the two toolchain helpers. The wheel ships no C++ sample tooling; on Windows it keeps only windows_argv.bat, for its Python .bat launchers. Release verification rejects an SDK archive without sample_python.py, or a Windows SDK archive without sample_build_root.bat.

  • scripts/prepare_python_wheel.py prunes the wheel staging copy with native_development_members() from scripts/verify_release_artifact.py. Under samples/, that rule matches C and C++ sources, CMakeLists.txt, build_samples.*, run_*_cpp.* and .exe files. Release verification rejects a wheel that still holds one.

  • scripts/test_python_wheel.cmake requires samples/ovclash_backend.txt, samples/sample_python.py, the three run_*_python launchers of the platform, the fixtures and, on Windows, windows_argv.bat.

  • The install step uses USE_SOURCE_PERMISSIONS, so the run_*.sh launchers 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

clash_api python, clash_api cpp

test_single_sample.cmake

Runs the launcher with --config, --backend, --install-root and --output-dir. check_sample_outputs.py then compares the five JSON summaries with the expected results. The cpp task also runs check_sample_threading.py on the built executable.

clash_suite_api python, clash_suite_api cpp

test_single_sample.cmake, then test_samples_default_clashdb.cmake

The same launcher run and output check, on the JSON export rows, the HTML file and the .ovclashdb of each case. Then the persistence-output cases of the sample gate. The two steps share one C++ build directory, so they run in sequence.

run_custom_clash

test_samples_custom_clash.cmake

A run without outputs, a run with outputs, the pick-up of the local _build/install/<backend> tree and, on Windows, a checkout path and values with cmd metacharacters.

legacy_clash_detection python, legacy_clash_detection cpp

test_samples_legacy_clash_detection.cmake

A launcher run that creates the missing input. check_sample_legacy_inputs.py then reruns the built sample: a legacy container and a plain SQLite store must open unchanged; a plain SQLite file named .clashDetection and a container without a SQLite payload must be rejected.

How the tasks run:

  • test_samples.cmake finds launchers with the glob samples/*/run_*<suffix>. It takes the language from the last _ token of the file name: run_clash_api_python gives python. It skips clash_suite_api and legacy_clash_detection, which have their own tasks. It also skips ovrtx_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_TESTS is on. test_samples.cmake reads 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

stats

dict[str, int]

Yes

Keys meshes, shared_meshes, cooked_meshes, point_clouds

The expected query statistics

overlaps

list[dict]

Yes

One dictionary per overlap, such as clash_id, name0, name1, type, mesh_crc_a, mesh_crc_b, elements, records, time, min_distance, max_local_depth and report

The expected clash_api overlap summaries

duplicates

list[dict]

No

[]

The expected duplicate summaries, in order

suite_rows

list[list[str]]

Yes

One list of cell texts per row

The expected clash_suite_api JSON export rows

point_row_count

int or None

No

None, no claim

How many export rows name a /Root/Points/ prim as Object A

  • For clash_api, it checks each summary’s backend, overlap and duplicate counts and full statistics. It matches overlaps by clash_id and compares names, type, mesh CRCs, element and record counts and the report sizes exactly. Time, distance, depth and point size may differ by at most 2e-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 .ovclashdb file is not empty.

  • For every pair, it recomputes the public clash ID from the two prim paths.

  • Any other --sample name 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 EXPECTED for both backends. Keep the tables identical except for documented backend differences.

  • Name a new launcher run_<sample>_<language>.sh or .bat. The glob and test_single_sample.cmake depend on that name. A launcher that test_single_sample.cmake drives must accept --config, --backend, --install-root and --output-dir.

  • Add a new product sample to the wheel list in scripts/build_wheel.cmake and to the required wheel members in scripts/test_python_wheel.cmake. The install tree picks it up through its CMakeLists.txt.

  • List every fixture that a launcher opens as ../data/<name> in scripts/sample_data_files.cmake. A sample README names such a fixture as ../data/<name>, because no package contains tests/data.

  • Commit run_*.sh launchers with mode 755. test_sample_launchers_ship_executable in tests/python_tests/test_build_script_contracts.py checks 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.