chore(keysight): add typed channel support - #426
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
Claude finished @maxleblang's task in 34m 34s —— View job Review: chore(keysight): add typed channel support
Overview: Small, well-scoped change —
The first two are worth fixing before merge; the rest are minor. |
Greptile SummaryThe PR adds typed voltage-input configuration support to the Keysight 34980A driver while explicitly rejecting unsupported typed current and thermocouple configurations.
Confidence Score: 5/5The 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
Reviews (1): Last reviewed commit: "fix" | Re-trigger Greptile |
| ) | ||
| ) | ||
|
|
||
| def configure_ai_voltage_channel(self, channel: AnalogVoltageChannel): |
There was a problem hiding this comment.
Only new typed channel function the we're adding support for in the KeySight driver. Copied over existing logic
|
|
||
| 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) |
There was a problem hiding this comment.
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.
| 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, | ||
| ) | ||
| ) | ||
|
|
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
This function is being deprecated anyway.
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
…yped-modules Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Summary
This "adds" typed channel support to the
Keysight34980Adriver. 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 oldconfigure_ai_channel()logic to the newconfigure_ai_voltage_channel()method and raiseNotImplementedfor all other typed channel configs.Closes INSTRO-508
Type of change
fix)feat)feat!/fix!)refactor)docs)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
Checklist
feat(driver): add support for Keysight E36300)