OpenHTF Examples
Runnable OpenHTF example scripts, one per feature — hello world, measurements, plugs, phase groups, branches, checkpoints, repeat, stop on first failure, custom JSON output, Operator UI — each explained line by line.
Last updated · Verified with OpenHTF 1.6.1
The OpenHTF repository ships an examples/ directory. Each page below takes one of those scripts, trims the boilerplate, explains what it demonstrates and shows its output. All were run against OpenHTF 1.6.1.
pip install "openhtf[examples]" # pandas, for measurements.py
python hello_world.pyStart here
Hello world
One phase, one measurement, JSON output, DUT prompt.
Measurements
Every way to declare and set a measurement, incl. multi-dimensional and marginal.
With plugs
Reuse one phase across several plug subclasses with with_plugs() and with_args().
Frontend example
Serve the Operator UI and run five tests back to back.
All the things
Plugs, monitors, dimensions, attachments, templated limits and three output callbacks in one script.
Feature showcases
Phase groups
Six scenarios showing when teardown runs.
Phase branches
Diagnosers and BranchSequence drive an interactive test.
Checkpoints
Skip a long burn-in when calibration failed.
Repeat
Retry a phase with PhaseResult.REPEAT and repeat_limit.
Stop on first failure
Two ways to set the option.
Ignore early-canceled tests
Subclass OutputToJSON to drop aborted records.
Tutorial
The resistor tutorial builds a complete test with two instrument plugs and a simulation mode, step by step.
Conventions used in these pages
- Scripts are shown as single files you can copy. Where upstream imports a sibling module (
example_plugs,examples.measurements) the needed code is inlined. - Output blocks are trimmed to the relevant lines; timestamps and paths vary.
- Scripts that prompt the operator (
prompt_for_test_start,UserInput.prompt) are run from a terminal; the Operator UI shows the same prompts in the browser.
Decorators
Learn how to use OpenHTF decorators to enhance your test phases with measurements, hardware plugins, and execution configuration.
Hello world
The canonical OpenHTF hello_world.py example explained — one phase, one measurement, a JSON output callback and a DUT ID prompt — with its console and JSON output.