Skip to content

chore(keysight): add typed channel support - #426

Open
maxleblang wants to merge 10 commits into
mainfrom
instro-508-keysight-typed-modules
Open

chore(keysight): add typed channel support#426
maxleblang wants to merge 10 commits into
mainfrom
instro-508-keysight-typed-modules

Conversation

@maxleblang

@maxleblang maxleblang commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

This "adds" typed channel support to the Keysight34980A driver. We aren't adding TC or current support, and the existing driver has no support for voltage ao, so all this PR is doing is copying the old configure_ai_channel() logic to the new configure_ai_voltage_channel() method and raise NotImplemented for all other typed channel configs.

Closes INSTRO-508

Type of change

  • Bug fix (fix)
  • New feature (feat)
  • Breaking change (feat! / fix!)
  • Refactor (refactor)
  • Documentation (docs)
  • Chore / tooling (chore)

Verification

Python test suite passes. I don't have a KeySight DAQ to test with, but no new functionality was introduced (@hoehner can you verify hardware tests pass on your side still?).

Tests

  • Unit tests added or updated
  • Existing tests cover this change
  • No tests — explain why:

Checklist

  • PR title follows Conventional Commits (e.g. feat(driver): add support for Keysight E36300)
  • I have read CONTRIBUTING.md
  • Documentation updated if user-facing behavior changed
  • Code follows the style/conventions of the surrounding code

@maxleblang
maxleblang requested review from hoehner and nhschwab August 24, 2026 15:55
@mintlify

mintlify Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
instro 🟢 Ready View Preview Aug 24, 2026, 3:58 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@claude

claude Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Claude finished @maxleblang's task in 34m 34s —— View job


Review: chore(keysight): add typed channel support

  • Gather context (AGENTS.md conventions, diff vs origin/main)
  • Review driver changes for convention/defect issues
  • Post inline comments
  • Post overview

Overview: Small, well-scoped change — configure_ai_voltage_channel duplicates the existing configure_ai_channel SCPI logic and the other typed methods correctly raise NotImplementedError per the base-class "contract surface" pattern (no premature abstraction attempted). Two real defects found in the backward-compat shim and docs, plus a coverage gap since the only Keysight tests are hardware-marked (excluded from PR CI). Details posted as 6 inline comments on the diff:

Severity Finding Location
Bug Deprecated configure_ai_channel shim stores an AnalogVoltageChannel instead of the caller's AnalogChannel, changing _channel_kind() output from "analog_input" to "voltage_input" keysight_34980a.py:150
Bug Docs sentence ends with a bare semicolon — continuation clause dropped daq.mdx:272
Convention configure_ai_voltage_channel has no mocked-transport unit test (hardware tests don't run in CI) keysight_34980a.py:151
Convention Two-sentence docstring violates the one-line-max rule (INSTRO-248) keysight_34980a.py:138
Cleanup Deprecated shim emits no DeprecationWarning keysight_34980a.py:134
Cleanup Manual 7-field copy will silently drop any future optional field added to AnalogChannel keysight_34980a.py:139-149

The first two are worth fixing before merge; the rest are minor.

@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds typed voltage-input configuration support to the Keysight 34980A driver while explicitly rejecting unsupported typed current and thermocouple configurations.

  • Routes legacy analog-input configuration through the new typed voltage-input implementation without losing channel fields.
  • Documents the Keysight driver's typed-channel capabilities.
  • Refreshes editable workspace package versions in uv.lock.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The typed voltage path preserves all legacy channel fields and existing SCPI configuration behavior, while unsupported typed channel operations continue to fail explicitly.

Important Files Changed

Filename Overview
instro/daq/drivers/keysight_34980a.py Adds typed voltage-input dispatch and explicit unsupported typed methods while preserving the existing Keysight voltage configuration behavior.
docs/guides/instrumentation/daq.mdx Documents which typed channel methods the Keysight 34980A supports.
uv.lock Updates only editable workspace package versions; flagged third-party dependency versions are unchanged from the base branch.

Reviews (1): Last reviewed commit: "fix" | Re-trigger Greptile

)
)

def configure_ai_voltage_channel(self, channel: AnalogVoltageChannel):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only new typed channel function the we're adding support for in the KeySight driver. Copied over existing logic

Comment thread instro/daq/drivers/keysight_34980a.py

def configure_ai_voltage_channel(self, channel: AnalogVoltageChannel):
"""Configure an AI voltage channel: ``CONF:VOLT:DC`` at computed range, then add to ``ROUT:SCAN`` and enable timestamps."""
range = self._compute_ai_range(channel)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convention: configure_ai_voltage_channel has no mocked-transport unit test in CI

AGENTS.md requires: "Add targeted tests in tests/<category>/test_<category>_drivers.py. The canonical pattern … patch the driver's VisaDriver reference with autospec=True, assert wire-level commands."

This method sends three SCPI commands (CONF:VOLT:DC {range}, 0.003, (@…), ROUTe:SCAN:ADD (@…), timestamp commands) and calls _check_errors, but tests/daq/test_daq_drivers.py has zero Keysight-specific tests. The only Keysight test file (tests/daq/keysight34980A/test_keysight_34980A_hardware.py) is @pytest.mark.hardware and excluded from PR CI. A typo in any SCPI format string passes CI undetected.

A minimal test that patches instro.daq.drivers.keysight_34980a.VisaDriver with autospec=True and asserts the write call sequence would cover this.

Comment thread docs/guides/instrumentation/daq.mdx Outdated
Comment thread instro/daq/drivers/keysight_34980a.py
Comment thread instro/daq/drivers/keysight_34980a.py
Comment thread instro/daq/drivers/keysight_34980a.py
Comment on lines +139 to +149
AnalogVoltageChannel(
physical_channel=channel.physical_channel,
alias=channel.alias,
direction=channel.direction,
range_max=channel.range_max,
range_min=channel.range_min,
scaler=channel.scaler,
terminal_config=channel.terminal_config,
)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup: 7-field manual copy silently drops any new field added to AnalogChannel

The shim lists all 7 current fields by name. AnalogChannel and AnalogVoltageChannel are sibling types with the same fields today, but the explicit constructor means any new optional field added to AnalogChannel (with a default) would be silently passed at its default rather than the caller's value — mypy only catches required fields.

AnalogVoltageChannel(**dataclasses.asdict(channel)) is the mechanically equivalent, more robust form:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is being deprecated anyway.

maxleblang and others added 2 commits August 24, 2026 12:55
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
maxleblang and others added 2 commits August 24, 2026 12:59
…yped-modules

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant