Attachments

Manufacturing tests often generate more than just status or test steps; they can produce logs, pictures, PDFs, and more. Tofupilot allows to easily upload these files with the test runs.

This guide shows how to attach one or several files during the creation of a run in Tofupilot and view them on the Run page.

Example

To log test attachments, this script defines a test function, captures its results along with associated files, and uploads them to the attachments field in create_run.

create_run_with_attachments.py

from tofupilot import TofuPilotClient
import json
import matplotlib.pyplot as plt

client = TofuPilotClient()

def generate_json_file():
    with open('test_result.json', 'w') as f:
        json.dump({"test_result": "pass", "details": {"measurement": "temperature", "value": 23.5}}, f)

def generate_temperature_graph():
    plt.plot([0, 1, 2, 3, 4, 5], [22, 23, 23.5, 24, 23.8, 23.5])
    plt.xlabel('Time (s)')
    plt.ylabel('Temperature (C)')
    plt.title('Temperature Sensor Measurements')
    plt.savefig('temperature-map.png')

def test_function():
    generate_json_file()
    generate_temperature_graph()
    return True, ['temperature-map.png', 'test_result.json']

run_passed, attachments = test_function()

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

Run Page

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

Attachments of Runs

Attachments can be viewed in the browser or downloaded.

Was this page helpful?