refactoring_branch: tooling, CI, documentation, and structural refactoring#3
Closed
Copilot wants to merge 3 commits into
Closed
refactoring_branch: tooling, CI, documentation, and structural refactoring#3Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/OpenwaterHealth/openlifu-sdk/sessions/0b696c10-0b7e-433c-a117-0c21c5b80e26 Co-authored-by: georgevigelette <114104081+georgevigelette@users.noreply.github.com>
…IBUTING, CHANGELOG) Agent-Logs-Url: https://github.com/OpenwaterHealth/openlifu-sdk/sessions/0b696c10-0b7e-433c-a117-0c21c5b80e26 Co-authored-by: georgevigelette <114104081+georgevigelette@users.noreply.github.com>
…tions, review fixes Agent-Logs-Url: https://github.com/OpenwaterHealth/openlifu-sdk/sessions/0b696c10-0b7e-433c-a117-0c21c5b80e26 Co-authored-by: georgevigelette <114104081+georgevigelette@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
georgevigelette
April 2, 2026 03:20
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements all recommendations from the architectural review. Changes are organized into 5 phases.
Phase 1 – Bug Fixes
Logging library contract violations
LIFUUart.pyandLIFUTXDevice.py: Removedpropagate = False, hardcodedsetLevel(ERROR), and manualStreamHandlersetup. Libraries must never configure the root logging hierarchy. Logger names changed from hardcoded strings to__name__.Shared mutable state bug
LIFUInterface:signal_connect,signal_disconnect,signal_data_received,hvcontroller, andtxdevicewere declared as class-level attributes — all instances shared the same signal objects. Moved to__init__as properly typed instance attributes.F-string logging (lazy evaluation)
logger.error(f"msg {x}")withlogger.error("msg %s", x)acrossLIFUTXDevice.py,LIFUHVController.py,LIFUUart.py,LIFUInterface.py, andLIFUUserConfig.py.Other code quality fixes
logging.warnuseless expression incalc_pulse_pattern→logger.warning(...)raise ValueError(...)insideexceptto chain withfrom e(PEP 3134 / ruff B904)n_detected_tx / TRANSMITTERS_PER_MODULE— now assigned ton_moduleswith a debug logset_solution— now assigned to named variables with an explanatory commentLIFUConfigimport (E402) — moved to top of file alongside all other importspyproject.toml
[test]and[dev]optional-dependency groups;[dev]now addspre-commit,ruff, andmypyPhase 2 – Tooling
pyproject.tomladditionsE,W,F,I,UP,B,G(logging f-strings),LOG,C4,PIE,RUF; line length 120ignore_missing_imports = truetestpaths = ["unit-test"],-vaddoptssrc/, excludes firmware/libusb binariesNew files
.pre-commit-config.yaml: ruff (lint + format), pre-commit-hooks (trailing whitespace, YAML/TOML check, large-file guard, no-commit-to-main).editorconfig: UTF-8, LF, 4-space indent, 120 max line for PythonPhase 3 – CI
.github/workflows/test.yml— runs on every push and pull request:lintjob:ruff check src/+ruff format src/ --checktestjob (depends on lint):pytest unit-test/ -v --cov=src --cov-report=xmlacrossubuntu-latest,windows-latest,macos-latest; uploadscoverage.xmlartifact from Ubuntu runpermissions: contents: read(CodeQL clean)Phase 4 – Documentation
README.md: Added CI/PyPI/Python/License badges; Features section; architecture tree; examples section; test & build instructions; links to CONTRIBUTING and CHANGELOGCONTRIBUTING.md: Full contributor guide — virtual env setup, project structure, coding conventions (logging rules, type annotations, docstrings, exception chaining), test/lint/pre-commit instructions, PR and release processCHANGELOG.md: Keep-a-Changelog format documenting all Phase 1–5 changes; links to GitHub compare URLsPhase 5 – Structural Refactoring
Beamforming extraction
LIFUTXDevice.pywas 2 623 lines mixing UART command wrappers with register-map math. The TX7332 register-map domain is now isolated in a new package:LIFUTXDevice.pyis now ~1 735 lines and re-exports all extracted names for full backward compatibility — existing imports (from openlifu_sdk.io.LIFUTXDevice import Tx7332DelayProfile) continue to work unchanged.Transport Protocol
src/openlifu_sdk/transport.py: A@runtime_checkableProtocolclass (Transport) that formally defines the interface expected byTxDeviceandHVController. Any class withdemo_mode,asyncMode,is_connected(),check_usb_status(),send_packet(),clear_buffer(), anddisconnect()satisfies the protocol — enabling test doubles without inheritance.SDK Exception Hierarchy
src/openlifu_sdk/exceptions.py:Updated public API
src/openlifu_sdk/__init__.pynow exportsLIFUInterface,LIFUInterfaceStatus, all exceptions, andTransport.Verification
ruff check src/ && ruff format src/ --check— fully clean (0 errors)