Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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 @@ -7,7 +7,9 @@ def phase_one():


def main():
test = htf.Test(phase_one, procedure_id="FVT1", part_number="PCB01") # Specify procedure and part_number
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)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import random
from datetime import datetime

from tofupilot import MeasurementOutcome, PhaseOutcome, TofuPilotClient
import random

client = TofuPilotClient()

Expand Down Expand Up @@ -34,7 +35,8 @@ def main():
procedure_id="FVT1", # Create the procedure first in the Application
unit_under_test={"serial_number": "PCB1A001", "part_number": "PCB1"},
phases=phases,
run_passed=all(phase["outcome"] == PhaseOutcome.PASS for phase in phases),
run_passed=all(
phase["outcome"] == PhaseOutcome.PASS for phase in phases),
)


Expand Down
Loading