Steps

Hardware manufacturing tests often involve multiple steps such as connections, measurements, calibration, and more. Tofupilot offers a simple way to record the details of these steps and analyze their performance across all executions.

This guide shows how to create and add various test steps in Tofupilot and view the automatically generated reports. This helps you quickly identify frequent failures and time-consuming steps, allowing you to focus on improvements.

Example

To log test step details, this script defines test functions, runs them sequentially, captures their results, and adds them to the steps table in create_run.

create_run_with_steps.py

from tofupilot import TofuPilotClient
from datetime import datetime

client = TofuPilotClient()

# Simple true/false step
def step_connect():
    return True,

# Step with a measurement value and unit
def step_initial_charge_check():
    initial_charge = 80
    return True, initial_charge, "%"

# Step with a measurement and a lower limit
def step_initial_temp_check():
    initial_temp = 72.0
    limit_low = 0.0
    return initial_temp >= limit_low, initial_temp, "°C", limit_low

# Step with a measurement, lower limit, and upper limit
def step_temp_calibration():
    calibrated_temp = 75.0
    limit_low = 70.0
    limit_high = 80.0
    return limit_low <= calibrated_temp <= limit_high, calibrated_temp, "°C", limit_low, limit_high

# Simple step sequencer and logger
def run_all_tests():
    tests = [func for name, func in globals().items() if callable(func) and name.startswith("step_")]
    steps, all_passed = [], True

    for t in tests:
        start = datetime.now()
        passed, value, unit, low, high = (t() + (None,) * 4)[:5]  # unpack with default None
        end = datetime.now()
        steps.append({
            "name": t.__name__,
            "started_at": start,
            "duration": end - start,
            "step_passed": passed,
            "measurement_value": value,
            "measurement_unit": unit,
            "limit_low": low,
            "limit_high": high
        })
        all_passed &= passed

    return all_passed, steps

run_passed, steps = run_all_tests()

client.create_run(
    procedure_id="FVT1",
    unit_under_test={
      "serial_number": "00102",
    },
    run_passed=run_passed,
    steps=steps,
)

Run Page

A dedicated Steps section is automatically created on the Run’s page.

Steps of Run

Procedure Page

The Procedure page provides a summary of the steps' run count, status, and average duration in the Steps section:

Steps Runs of Procedures

Run Duration

If no total test duration is provided, it will be computed as the sum of the durations of all the steps. However, if a total test duration is specified, it will override the computed sum.

API Reference

Each step in the steps array provided to create_run should include the following parameters:

Required

  • Name
    name
    Type
    string
    Description

    Name of the step.

  • Name
    started_at
    Type
    datetime
    Description

    Timestamp when the step started.

  • Name
    duration
    Type
    timedelta
    Description

    Duration of the step in seconds.

  • Name
    step_passed
    Type
    boolean
    Description

    Indicates whether the step passed.

Optional

  • Name
    measurement_value
    Type
    number or None
    Description

    Value measured during the step, if any.

  • Name
    measurement_unit
    Type
    string or None
    Description

    Unit of the measurement value, if any.

  • Name
    limit_low
    Type
    number or None
    Description

    Lower limit for the measurement, if any.

  • Name
    limit_high
    Type
    number or None
    Description

    Upper limit for the measurement, if any.

Was this page helpful?