Samples#
ovclash ships three runnable samples, with launchers that set up the runtime and run example
queries. The clash_suite_api sample also holds the Clash Processor, a command-line program that
runs queries on your own stages without code.
This page ships as docs/consumer/samples.md in the SDK archive. Paths
on this page are relative to the package root:
In the wheel, the package root is the installed
ovclashpackage directory,<site-packages>/ovclash/.python -m pip show ovclashprints<site-packages>asLocation.In the SDK archive, the package root is the
ovclash/directory that the archive unpacks to.
Samples map#
Sample |
Covers |
Read next |
|---|---|---|
|
The clash C ABI of the canonical API and its |
|
|
The Suite API end to end, mirroring the clash examples of Kit in five cases: a static query, a dynamic query, duplicate search, a point-vs-mesh query against point clouds and its dynamic form, with |
|
|
Reading and writing the legacy |
Each sample has a Python program and a C++ program that do the same work. Each sample directory
has a README.md that lists the options of its launchers. The clash_api and
legacy_clash_detection READMEs also list their programs’ options and show the expected output;
for clash_suite_api, the Clash Processor guide, samples/clash_suite_api/clash_processor.md,
holds them.
What each package ships#
Files |
Wheel |
SDK archive |
|---|---|---|
The Python programs: |
yes |
yes |
The Python launchers, |
yes |
yes |
|
yes |
yes |
Each sample’s |
yes |
yes |
|
yes |
yes |
|
yes |
yes |
|
yes |
yes |
The C++ programs ( |
no |
yes |
|
no |
yes |
A package carries the launchers for its own platform only: .sh launchers on Linux and .bat
launchers on Windows.
The wheel cannot build the C++ programs. With the SDK archive,
Building the C++ samples describes
samples/build_samples.sh and the run_<sample>_cpp launchers.
Running the Python samples#
A launcher finds its own location, so you can run it from any directory. From the package root, on Linux:
./samples/clash_api/run_clash_api_python.sh
./samples/clash_suite_api/run_clash_suite_api_python.sh
./samples/legacy_clash_detection/run_legacy_clash_detection_python.sh
On Windows:
samples\clash_api\run_clash_api_python.bat
samples\clash_suite_api\run_clash_suite_api_python.bat
samples\legacy_clash_detection\run_legacy_clash_detection_python.bat
The
clash_apiandclash_suite_apilaunchers run five example queries againstsamples/data/time_sampled.usda.The
legacy_clash_detectionlauncher createsinput.clashDetectionand writescopy.clashDetectionandcopy.ovclashdb.A launcher runs the library of the package that holds it.
The launchers share these options:
Option |
Launchers |
Default |
Effect |
|---|---|---|---|
|
|
|
The stage file of the example queries. |
|
All |
The package that holds the launcher |
Runs against the SDK archive whose root is |
|
All |
A directory inside the package root; see Output directories |
Where the examples write their results. |
|
All |
None |
Prints the launcher’s options and exits. |
Each sample’s README.md lists the remaining options of its launchers.
To run one command of your own instead of the examples, pass the program’s arguments after --.
The launcher forwards them unchanged. From the package root, on Linux:
./samples/clash_api/run_clash_api_python.sh -- --stage samples/data/time_sampled.usda --object-a /Root/Xform_Primitives/Cube --object-b /Root/Xform_Primitives/Plane --json static.json
On Windows:
samples\clash_api\run_clash_api_python.bat -- --stage samples\data\time_sampled.usda --object-a /Root/Xform_Primitives/Cube --object-b /Root/Xform_Primitives/Plane --json static.json
The command replaces the whole example command line, so it must name the stage.
The first argument that the launcher does not know also starts the command. You need
--only when the command starts with a launcher option such as--stage.Relative paths resolve against the current directory.
How the launchers select a runtime#
A packaged launcher imports the Python packages of the package that holds it, or of the SDK
archive that --install-root names, even when another ovclash is installed. It reads the
packaged backend from samples/ovclash_backend.txt.
The runtime helper, samples/sample_python.py, selects the interpreter:
It starts from the interpreter that
PYTHONnames, elsepython3on Linux orpythonon Windows. It ignores an inheritedPYTHONPATH.Wheel. It checks the ovstage that the launch imports, from the wheel’s site directory first. A complete installation of the exact pin there, as pip installs the dependency, runs offline without any setup. When that directory holds no ovstage and the interpreter imports no complete installation of the pin from elsewhere on its path, the helper prepares a cached environment. An
ovstagein the wheel’s site directory that is not a complete installation of the pin is an error that names the directory: the samples would import it first. The wheel’s launchers ignoreOVCLASH_OVSTAGE_PACKAGE_DIR.SDK archive. When the interpreter lacks a complete installation of the SDK archive’s exact pin, the helper prepares a cached environment, keyed by the SDK archive location, the exact ovstage pin and the base interpreter.
OVCLASH_OVSTAGE_PACKAGE_DIRnames another installation by the absolute path of itsovstagepackage directory. The launchers then prepare no cached environment, so they also work offline. A selection that is not the pinned version is an error.
A cached environment holds only the exact ovstage pin, installed with pip. It leaves the base interpreter’s packages unchanged. It lives under:
Platform |
Directory |
|---|---|
Windows |
|
Linux |
|
The first setup needs pip access to the pinned ovstage wheel and an interpreter that can create a virtual environment.
With pip 22.3 or newer in the base interpreter, setup uses that pip to install into the environment. Otherwise the environment must bootstrap pip itself; on Debian and Ubuntu that needs the
python3-venvpackage.pip runs in isolated mode, so a module in the launch directory is never imported. Your
PIP_*variables and pip configuration still apply, for example a package mirror.The first setup prints
Preparing isolated ovstage==<pin> sample environment at <directory>on stderr. A later launch reuses the environment.
A failed setup prints Sample Python setup failed:; see
Troubleshooting. A launcher copied out of its
package runs the helper of the install root that --install-root or OVCLASH_INSTALL_ROOT
selects, else the one in its own samples directory. When neither holds sample_python.py, it
stops with Sample Python setup helper not found at; see
Troubleshooting.
Output directories#
The launchers write their results to an output directory. By default it is created inside the
package root, with one directory per sample and backend. Pass --output-dir DIR to write
elsewhere, for example when the package root is read-only, as a system-wide Python installation
often is. From the package root, on Linux:
./samples/clash_suite_api/run_clash_suite_api_python.sh --output-dir "$HOME/clash_results"
On Windows, in Command Prompt:
samples\clash_suite_api\run_clash_suite_api_python.bat --output-dir "%USERPROFILE%\clash_results"
Launcher |
Writes |
Default for |
|---|---|---|
|
|
|
|
|
|
|
|
|
A custom command after -- writes only the outputs that its own arguments name, such as
--json PATH.
The Clash Processor#
The clash_suite_api Python program, clash_suite_api_python.py, is a clash processor: each
run executes one query through the Suite API, saves the results and exports reports. Its
command line supplies the stage, the search sets of the scope, the query
kind and times, the tolerance and the output paths. samples/clash_suite_api/run_custom_clash.sh
(run_custom_clash.bat on Windows) sets up a runtime and runs it with your arguments, without
--. From the package root, on Linux:
./samples/clash_suite_api/run_custom_clash.sh --stage samples/data/time_sampled.usda --object-a /Root/Xform_Primitives/Cube --object-b /Root/Xform_Primitives/Plane --json static.json --html static.html
On Windows:
samples\clash_suite_api\run_custom_clash.bat --stage samples\data\time_sampled.usda --object-a /Root/Xform_Primitives/Cube --object-b /Root/Xform_Primitives/Plane --json static.json --html static.html
The launcher owns four options:
Launcher option |
Default |
Effect |
|---|---|---|
|
The backend of the SDK archive that holds the launcher, else |
The backend to run. The released packages hold only |
|
The SDK archive that holds the launcher, else none |
Runs against the SDK archive whose root is |
|
Off |
Skips the SDK archive that holds the launcher and uses the published wheel, unless |
|
|
|
The launcher forwards every other argument to the processor unchanged. With no processor argument, or with
--help, it prints its own options and the processor’s, then exits with status 1.Inside an SDK archive, it runs against that SDK archive.
--install-root DIR, orOVCLASH_INSTALL_ROOT, selects another one.Elsewhere, including the copy in an installed wheel, it creates a virtual environment,
.venv-ovclashbeside the script, with the interpreter thatPYTHONnames, elsepython3(pythonon Windows). It installs theovclashwheel and its pinnedovstagethere from the package index thatOVCLASH_INDEX_URLnames, else from the index that pip’s configuration selects, and fails when that index does not host ovclash.--install-root DIRselects an SDK archive instead.--wheelselects this route inside an SDK archive too.When that setup fails, the launcher exits with status 1. A failed install prints
Could not install <spec> into "<dir>", where<spec>isovclash, orovclash==<version>whenOVCLASH_VERSIONnames a version, and<dir>is the virtual environment. WithoutOVCLASH_INDEX_URL, it addsOVCLASH_INDEX_URL is not set, so pip used its configured index, which may not host ovclash.SetOVCLASH_INDEX_URLto an index that hosts ovclash, give pip a mirror that does, or pass--install-root DIRto use an SDK archive. A failedCould not create the venv "<dir>" with "<python>"needs an interpreter that can create virtual environments: setPYTHONto one, or on Debian and Ubuntu installpython3-venv.OVCLASH_VERSIONpins the ovclash version of the first install; the default is the latest. A working environment is reused and not repinned, so delete.venv-ovclashto change the version.On Windows, quote a value that contains spaces,
,,;,=or one of& | < > ^, becausecmdsplits or interprets it first:--object-a "/Root/A,/Root/B".On Linux, quote a value that contains spaces or one of
; & | < >, because the shell splits or interprets it first.,and=need no quoting there:--object-a /Root/A,/Root/B.
The Clash Processor guide, samples/clash_suite_api/clash_processor.md, is the complete
reference: every processor option, the output stores, the exit statuses and recipes for common
queries. skills/ovclash-clash-processor/SKILL.md, in the package directory, keeps the shortest
command-line patterns.
Environment variables#
Each launcher variable presets an option or a default, and an option on the command line wins.
Environment variables lists every variable that a
consumer can set. Its table
Sample launchers and build_samples covers
the launchers, run_custom_clash and build_samples; OVCLASH_OVSTAGE_PACKAGE_DIR, which the SDK
archive’s launchers also read, is in its
Loading the library table.