Real-Time or Offline Test Sync?

TofuPilot displays the results of OpenHTF test scripts in real time.

Julien Buteau

1 min read

When developing or running tests in connected environments, you want to see results immediately. But testing doesn’t always happen online and offline uploads need to be possible, too. Our new release improves both scenarios.

Online Streaming

In connected environments, you want test results instantly, not after they finish. Our new release introduces real-time streaming for OpenHTF test scripts, powered by a new secure real-time infrastructure. Tests appear on your TofuPilot Runs page as soon as they start, with real-time step status tracking.

TofuPilot displays the results of OpenHTF test scripts in real time.
OpenHTF test results displayed in real time in TofuPilot.

No code changes are needed on your side—just update the TofuPilot Python client, and live streaming kicks in automatically.

Offline Synch

TofuPilot now offers improved support for offline uploads when test stations aren’t directly connected, allowing offline uploads without losing accuracy. With the optional “started_at” field, analytics reflect the actual test date instead of the upload date, and upload capacity is now up to 1,000 runs per minute.

main.py

import random
from datetime import datetime, timedelta

from tofupilot import TofuPilotClient

client = TofuPilotClient()


def simulate_test_result(yield_percentage):
    return random.random() < (yield_percentage / 100.0)


def battery_connection():
    passed = simulate_test_result(100)
    return passed, None, None, None, None


def check_voltage():
    passed = simulate_test_result(100)
    value_measured = (
        round(random.uniform(10.1, 12.0), 0)
        if passed
        else round(random.uniform(14.4, 15.0), 1)
    )
    return passed, value_measured, "V", None, 13


def flash_firmware():
    passed = simulate_test_result(90)
    value_measured = "1.2.4" if passed else "1.2.0"
    return passed, value_measured, None, None, None


# Running Tests
def run_test(test, duration):
    start_time = datetime.now() - timedelta(days=1)
    passed, value_measured, unit, limit_low, limit_high = test()

    step = {
        "name": test.__name__,
        "started_at": start_time,
        "duration": duration,
        "step_passed": passed,
        "measurement_unit": unit,
        "measurement_value": value_measured,
        "limit_low": limit_low,
        "limit_high": limit_high,
    }
    return step


def run_all_tests():
    tests = [
        (flash_firmware, timedelta(minutes=3, seconds=32)),
        (battery_connection, timedelta(seconds=8)),
        (check_voltage, timedelta(seconds=3)),
    ]

    steps = []
    total_duration = timedelta(0)

    for test, duration in tests:
        step = run_test(test, duration)
        steps.append(step)
        total_duration += duration

    return steps, total_duration


def handle_test():
    random_digits = "".join([str(random.randint(0, 9)) for _ in range(5)])
    serial_number = f"SI0364B{random_digits}"

    # Exécuter tous les tests
    steps, total_duration = run_all_tests()

    # Créer un rapport de test
    client.create_run(
        procedure_id="FVT9",
        unit_under_test={
            "part_number": "SI0364",
            "revision": "B",
            "batch_number": "01-25",
            "serial_number": serial_number,
        },
        run_passed=all(step["step_passed"] for step in steps),
        started_at=datetime.now() - timedelta(days=1),
        steps=steps,
    )


if __name__ == "__main__":
    handle_test()

Check out our new documentation page for more on this use case.

Updated Docs

We’ve revamped the TofuPilot docs with insights from our work on openhtf.org. You’ll find new guides, feature and code examples to help you get the most out of TofuPilot.

Screenshot of the updated TofuPilot documentation, showing the Quickstart section with new guides and examples.
Revamped TofuPilot docs—new guides, features, and code examples

Ready to get started?

Create a new workspace and start uploading your test data in seconds.

Not sure where to start? Talk to our team