Command-Line Flags
Every command-line flag an OpenHTF test script accepts — -v verbosity, --config-file, --config-value, --config-help — and the dashboard_server flags, with how to combine them with your own argparse.
Last updated · Verified with OpenHTF 1.6.1
An OpenHTF test is a plain Python script, but the framework registers a few flags that any script accepts once test.configure() or test.execute() has run.
python main.py -vv --config-file station_a.yaml --config-value station_id=EOL-01Flags every test accepts
-v, -vv, -vvvConsole log verbosity. No flag: framework logs only. -v: info and above from phases and plugs. -vv: debug and above. See Logger.
--config-file FILELoad configuration from a YAML or JSON file. Equivalent to CONF.load_from_file(). Values from the file override declared defaults.
--config-value KEY=VALUESet one configuration key. Repeatable. Overrides both defaults and the file. The value is always a string — cast in code if you need an int.
--config-helpPrint every declared configuration key with its description and default, then exit. Run it on your own test to document its knobs.
-h, --helpStandard argparse help, including the flags above.
Flags are parsed with parse_known_args(), so unknown flags are left alone for your own parser.
Combining with your own arguments
OpenHTF exposes its parsers as ARG_PARSER objects you can pass as parents:
import argparse
import openhtf as htf
from openhtf.util import configuration, logs
def main():
parser = argparse.ArgumentParser(
parents=[configuration.ARG_PARSER, logs.ARG_PARSER],
description="PCB01 end-of-line test",
)
parser.add_argument("--fixture", choices=["A", "B"], default="A")
args = parser.parse_args() # -v and --config-* still work
test = htf.Test(*phases_for(args.fixture))
test.execute(lambda: "SN1234")
if __name__ == "__main__":
main()dashboard_server flags
The multi-station dashboard is a separate entry point:
python -m openhtf.output.servers.dashboard_server --dashboard-server-port 12000 --no-launch-web-gui--dashboard-server-port PORT12000.--discovery-interval-s N1.--launch-web-gui / --no-launch-web-gui--no-local-only--station-discovery-address / --station-discovery-port / --station-discovery-ttl239.1.1.1, 10000, TTL 1. Must match the station_discovery_* configuration keys on the stations.Environment variables
OpenHTF itself reads none. TofuPilot's upload() callback reads TOFUPILOT_API_KEY (see Manufacturing Test Analytics). A common pattern is to gate optional phases on an environment variable with run_if — see Run if.
Related
Test Options
Reference for test.configure() in OpenHTF — test name, stop_on_first_failure, failure_exceptions, default_dut_id, diagnosers and output_callbacks — plus Test.execute() arguments.
Units
Searchable table of all 2,134 unit constants in openhtf.util.units — name, UNECE code and suffix — with how to attach units to measurements and dimensions and how to look a unit up by string.