Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b6aae57
Merge branch 'charlotte/fix-git-actions'
charlottEv Apr 29, 2025
452998a
Add comment next to all python procedure_id
charlottEv Apr 29, 2025
f041126
Merge branch 'charlotte/fix-procedure-id-for-documentation'
charlottEv Apr 29, 2025
45f6d2d
Add comments to openhtf to add procedure_id
charlottEv May 1, 2025
da54f96
Add MQTT to required python package
charlottEv May 1, 2025
37dc6ff
Add logger script to documentation
charlottEv May 1, 2025
0959b61
Add openhtf measurements script for documentation
charlottEv May 1, 2025
a5116d7
Add dimension measurement script in documentation
charlottEv May 1, 2025
67af5e4
Add python script for multi-measurement in documention
charlottEv May 1, 2025
cc780c4
Create new measurements repo in documentation
charlottEv May 5, 2025
b5f2a25
Fix string measurement in python
charlottEv May 5, 2025
23db729
Add example for logger with Python client
charlottEv May 5, 2025
fe4399a
Merge branch 'charlotte/new-features-ope-ui'
charlottEv May 5, 2025
32e017d
Fix timestamp format in Python logger client
upview May 5, 2025
42fe233
Auto code format
upview May 5, 2025
4131343
Merge pull request #57 from tofupilot/julien/app-3143
upview May 5, 2025
493b5ca
Improves comments in timestamp implementation
upview May 5, 2025
332f680
Auto code format
upview May 5, 2025
984be93
Merge pull request #58 from tofupilot/julien/app-3151
upview May 5, 2025
0b8492b
Improves multi dim examples
upview May 6, 2025
44add38
Auto code format
upview May 6, 2025
8adac98
Merge pull request #60 from tofupilot/julien/app-3167
upview May 6, 2025
341ca2b
Update get_runs() examples with attachments or saving in a json
charlottEv May 27, 2025
5cf044d
Merge branch 'quentin/app-3374'
charlottEv May 27, 2025
54bff6b
Rename qa directory to testing_examples
charlottEv Jul 14, 2025
ffcecbd
Merge branch 'charlotte/app-3886'
charlottEv Jul 14, 2025
be661b0
Add missing procedure_id to testing_examples
Sporarum Jul 23, 2025
aad0dc2
Merge pull request #66 from tofupilot/quentin/fix-missing-procedure-id
upview Jul 23, 2025
f81e65d
Remove old Git Actions and test scripts
charlottEv Aug 6, 2025
87fe565
Move doc examples in api_v1 folder
charlottEv Aug 6, 2025
cf586b2
Merge branch 'charlotte/app-4074'
charlottEv Aug 6, 2025
e4ce697
Add assembly test with multi-dimensional voltage sampling
claude Nov 10, 2025
e682c0c
Auto code format
charlottEv Nov 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions .github/workflows/run-templates.yml

This file was deleted.

74 changes: 0 additions & 74 deletions .github/workflows/test-scripts.yml

This file was deleted.

76 changes: 0 additions & 76 deletions api/index.py

This file was deleted.

1 change: 0 additions & 1 deletion docs_openhtf/attachments/by_path/data/sample_file.txt

This file was deleted.

20 changes: 0 additions & 20 deletions docs_openhtf/attachments/by_path/main.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,43 @@ def voltage_value():
return passed, value_measured, "V", 10.0, 12.0


def voltage_sampling_test():
"""
Multi-dimensional voltage sampling test.
Samples 100 voltage measurements over time.
Returns: (passed, measurements, units, limit_low, limit_high)
where measurements is a list of (timestamp, voltage) tuples
"""
passed_prob = 0.98
num_samples = 100
limit_low = 10.0
limit_high = 12.0

measurements = []
all_passed = True

# Simulate voltage measurements over time
for i in range(num_samples):
timestamp = i / num_samples # Time in seconds (0 to 0.99)

# Determine if this sample should pass
sample_passed = simulate_test_result(passed_prob)

if sample_passed:
voltage = round(random.uniform(limit_low, limit_high), 2)
else:
voltage = round(random.uniform(8.0, 9.5), 2)
all_passed = False

measurements.append((timestamp, voltage))

# Return multi-dimensional measurement
# Format: (passed, value_measured, unit, limit_low, limit_high)
# For multi-dimensional, value_measured is the list of tuples
# and unit should be a list of units for each dimension
return all_passed, measurements, ["s", "V"], limit_low, limit_high


def internal_resistance():
passed = simulate_test_result(0.98)
value_measured = (
Expand Down Expand Up @@ -349,10 +386,13 @@ def execute_procedures(end):
if not passed_cell:
continue

# Execute Assembly Tests
# Execute Assembly Tests with voltage sampling
tests_assembly = [
(battery_connection, timedelta(seconds=0.1)),
(voltage_value, timedelta(seconds=1)),
(
voltage_sampling_test,
timedelta(seconds=10),
), # New multi-dimensional test
(internal_resistance, timedelta(seconds=1)),
(thermal_runaway_detection, timedelta(seconds=2)),
(state_of_health, timedelta(seconds=2)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def main():
attachments = phase_file_attachment()

client.create_run(
procedure_id="FVT1",
procedure_id="FVT1", # Create the procedure first in the Application
unit_under_test={"serial_number": "PCB1A001", "part_number": "PCB1"},
run_passed=True,
attachments=attachments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ def phase_file_attachment(test):
def main():
test = htf.Test(
phase_file_attachment,
procedure_id="FVT1",
part_number="PCB1")
procedure_id="FVT1", # Create the procedure first in the Application
part_number="PCB1",
)

with TofuPilot(test):
test.execute(lambda: "PCB1A001")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def main():
client = TofuPilotClient()

client.create_run(
procedure_id="FVT1", # Define the TofuPilot's procedure ID
procedure_id="FVT1", # Create the procedure first in the Application
unit_under_test={
"serial_number": "PCB1A001",
"part_number": "PCB1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
from tofupilot.openhtf import TofuPilot # Import OpenHTF for TofuPilot


def phase_one(test):
def phase_one():
return htf.PhaseResult.CONTINUE


def main():
test = htf.Test(phase_one)
test = htf.Test(
phase_one, procedure_id="FVT1", part_number="PCB01"
) # Specify procedure and part_number

with TofuPilot(test): # One-line integration
test.execute(lambda: "PCB1A001")
Expand Down
61 changes: 61 additions & 0 deletions docs_tofupilot/api_v1/logger/client/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import logging
import sys
from datetime import datetime

from tofupilot import TofuPilotClient


class TofuPilotLogHandler(logging.Handler):
"""Handler that captures logs in a format compatible with TofuPilot API."""

def __init__(self):
super().__init__()
self.logs = []

def emit(self, record):
# Format log with ISO-8601 timestamp (UTC, ms) for TofuPilot API
log_entry = {
"level": record.levelname,
"timestamp": datetime.utcfromtimestamp(record.created).isoformat(
timespec="milliseconds"
)
+ "Z",
"message": record.getMessage(),
"source_file": record.filename,
"line_number": record.lineno,
}
self.logs.append(log_entry)


# Initialize the TofuPilot client to report test results
client = TofuPilotClient()

# Set up local logger with custom name and prevent propagation to parent
# loggers
local_logger = logging.getLogger("test_logger")
local_logger.setLevel(logging.DEBUG)
local_logger.propagate = False

# Add handlers: one for TofuPilot API capture and one for console output
capture_handler = TofuPilotLogHandler()
local_logger.addHandler(capture_handler)
local_logger.addHandler(logging.StreamHandler(sys.stdout))


# Log examples at different severity levels
local_logger.debug("Debug message: Detailed information for troubleshooting")
local_logger.info("Info message: Normal operation information")
local_logger.warning("Warning: Something unexpected but not critical")
local_logger.error("Error: A significant problem that needs attention")
local_logger.critical("Critical: System unstable, immediate action required")

# Create a run and send captured logs to TofuPilot
try:
client.create_run(
procedure_id="FVT1",
unit_under_test={"serial_number": "00007035", "part_number": "LOGS01"},
run_passed=True,
logs=capture_handler.logs,
)
finally:
local_logger.removeHandler(capture_handler)
Loading