TofuPilotTofuPilot

String

Record string values with pattern validation.

MAC Address
AC:19:4F
xmatches/^[A-F0-9:]+$/
Pass
Error Message
Invalid config
xmatches/^OK$/
Fail
Batch Number
LOT-123
x==LOT-123
Pass

You can create a string measurement with measurements:

measurements:
  - name: Error Message
    validators: 
      - operator: matches
        expected_value: "^OK$"

You can set the measurement value in your Python phase:

def check_status(run, measurements, device):
    message = device.get_error_message()
    measurements.error_message = message 

Definition

You can configure the measurement name and metadata.

PropertyTypeRequiredDescription
keystringNoUnique identifier for the measurement within the phase
namestringYesDisplay name (1-100 characters)
unitstringNoMeasurement unit (e.g., "sn", "ver", max 50 characters)
descriptionstringNoDetailed description (max 50,000 characters)

TofuPilot auto-generates the key from name (snake_case) if not specified, and uses it for Python access (e.g., measurements.serial_number). The unit and description display in the web interface and reports.

Validators

You can add one or several validators to your measurement using the following properties:

PropertyTypeRequiredDescription
operatorstringYesComparison operator
expected_valuestring or arrayYesExpected value(s) or regex pattern

You can use the following operators for string measurements:

OperatorExpected ValueDescriptionExample
==StringValue must equal expectedexpected_value: "PASS"
!=StringValue must not equal expectedexpected_value: "ERROR"
inArray of stringsValue must be in the arrayexpected_value: ["v1.0.0", "v1.0.1"]
not inArray of stringsValue must not be in the arrayexpected_value: ["FAIL", "ERROR"]
matchesRegex patternValue must match regex patternexpected_value: "^SN[0-9]{8}$"

TofuPilot evaluates validators and sets the outcome to Pass if met, Fail if not, or Unset if no value provided.

Examples

Pattern Matching with Regex

We will validate error messages match expected pattern:

phases:
  - name: Error Message Check
    python:
      module: check_errors
    measurements:
      - name: Error Message
        description: Error message from device diagnostic
        validators:
          - operator: matches
            expected_value: "^(OK|PASS|SUCCESS)$"
def check_errors(run, measurements, device):
    log.info("Checking device error message")

    message = device.get_error_message()
    measurements.error_message = message

    if not message in ["OK", "PASS", "SUCCESS"]:
        log.warning(f"Unexpected message: {message}")

Status Code Validation

We will validate device status codes with array matching:

phases:
  - name: Status Check
    python:
      module: check_status
    measurements:
      - name: Device Status
        description: Device operational status code
        validators:
          - operator: in
            expected_value: ["OK", "READY", "IDLE"]
          - operator: not in
            expected_value: ["ERROR", "FAULT", "FAILED"]
def check_status(run, measurements, device):
    log.info("Reading device status")

    status = device.get_status()
    measurements.device_status = status

    if status in ["ERROR", "FAULT", "FAILED"]:
        log.error(f"Device in error state: {status}")

How is this guide?