Repository navigation
feat: add Ctrl-] x3 hotkey to power cycle board from serial console - #791
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Pre-merge checks:
|
LuuOW
left a comment
There was a problem hiding this comment.
Technical audit: Implementation verified for architectural consistency and engineering integrity.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client.py`:
- Around line 135-142: The `_search_power()` method only checks the children of
the provided client node but skips checking if the client node itself is
power-capable. This causes power-driver discovery to fail when the root node has
power capabilities. Modify the method to first check if the current `client`
parameter has a `cycle` method or both `on` and `off` methods before recursing
into `client.children`, ensuring the root node is included in the power-driver
discovery process.
In
`@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/console_test.py`:
- Around line 17-37: The slave_file opened via os.fdopen() in the
_start_console() function is never explicitly closed, causing file descriptor
leaks across multiple test runs. Ensure proper cleanup by either returning
slave_file as part of the function's return tuple so the caller can close it
after the thread completes, or by adding a cleanup mechanism that closes
slave_file after the console.run() thread finishes executing. The key is to
guarantee that the file handle opened for slave_fd is properly closed to prevent
descriptor exhaustion.
In
`@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/console.py`:
- Around line 47-52: The exception re-raising in the except* ConsoleStreamDrop
and except EndOfStream blocks violates Ruff B904 linting rules by not using
explicit exception chaining. For each exception handler block that raises an
exception (the except* ConsoleStreamDrop block that raises ConsoleStreamDrop()
and the except EndOfStream block that raises ConsoleStreamDrop()), capture the
caught exception as a variable in the except clause (e.g., except*
ConsoleStreamDrop as exc) and use the from keyword when raising to provide
explicit chaining (e.g., raise ConsoleStreamDrop() from exc). Alternatively, use
make lint-fix to automatically apply the necessary fixes to satisfy B904
requirements.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7c042f0b-f525-40fa-9c8d-e51bfe0279df
📒 Files selected for processing (4)
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client.pypython/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/console.pypython/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/console_test.pypython/packages/jumpstarter/jumpstarter/client/client.py
67ebd74 to
beac1ee
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py (1)
8-33: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winConsolidate new driver-package tests into
driver_test.pyper repository policy.Both files add comprehensive driver-package test coverage, but not in the required module location.
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py#L8-L33: move/merge the power discovery and power-cycle tests intojumpstarter_driver_pyserial/driver_test.py.python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/console_test.py#L40-L91: move/merge the Ctrl-B/Ctrl-] integration tests intojumpstarter_driver_pyserial/driver_test.py.As per coding guidelines,
**/jumpstarter-driver-*/jumpstarter_driver_*/*_test.py: Add comprehensive tests indriver_test.pyfile within the driver package.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py` around lines 8 - 33, Move the power discovery and power-cycle tests (test_find_power_client_no_root, test_find_power_client_with_cycle, test_make_power_cycle_calls_cycle) from python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py lines 8-33 into python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/driver_test.py, and similarly move the Ctrl-B/Ctrl-] integration tests from python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/console_test.py lines 40-91 into the same driver_test.py file. Per the coding guidelines, comprehensive driver-package tests must be consolidated in the driver_test.py file within the driver package rather than scattered across individual module test files.Source: Coding guidelines
🧹 Nitpick comments (2)
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py (1)
24-33: ⚡ Quick winAdd coverage for the
_make_power_cyclefallback branch.
test_make_power_cycle_calls_cyclevalidates only thecycle()path; theoff()→sleep(2)→on()path inpython/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client.pyis still untested.💡 Suggested test addition
+def test_make_power_cycle_calls_off_on_when_cycle_missing(): + called_off = threading.Event() + called_on = threading.Event() + power = MagicMock(spec=["off", "on"]) + power.off = MagicMock(side_effect=lambda: called_off.set()) + power.on = MagicMock(side_effect=lambda: called_on.set()) + + with serve(PySerial(url="loop://")) as client: + cycle_fn = client._make_power_cycle(power) + client.portal.call(cycle_fn) + + assert called_off.is_set() + assert called_on.is_set()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py` around lines 24 - 33, The test_make_power_cycle_calls_cycle test only covers the cycle() code path in the _make_power_cycle method, but the fallback branch that uses off() followed by sleep(2) followed by on() remains untested. Add a new test case that mocks the power object to trigger the fallback path (either by not providing a cycle method or having it unavailable), then verify that the fallback sequence of off(), sleep(), and on() method calls is executed properly when the cycle function is invoked through client.portal.call().python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/console_test.py (1)
44-45: ⚡ Quick winReplace fixed sleeps with deterministic readiness signaling.
Line 44, Line 64, and Line 81 use
time.sleep(0.1)to assume console readiness; this can cause intermittent CI flakes.Also applies to: 64-65, 81-83
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/console_test.py` around lines 44 - 45, Replace the three instances of time.sleep(0.1) calls with deterministic readiness signaling instead of relying on fixed delays to assume console readiness. For each location where time.sleep(0.1) precedes an os.write operation, implement a proper synchronization mechanism such as using select, poll, or event-based signaling to confirm the file descriptor is actually ready for writing before proceeding, eliminating the intermittent CI flakes caused by timing assumptions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py`:
- Around line 8-33: Move the power discovery and power-cycle tests
(test_find_power_client_no_root, test_find_power_client_with_cycle,
test_make_power_cycle_calls_cycle) from
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py
lines 8-33 into
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/driver_test.py,
and similarly move the Ctrl-B/Ctrl-] integration tests from
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/console_test.py
lines 40-91 into the same driver_test.py file. Per the coding guidelines,
comprehensive driver-package tests must be consolidated in the driver_test.py
file within the driver package rather than scattered across individual module
test files.
---
Nitpick comments:
In
`@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py`:
- Around line 24-33: The test_make_power_cycle_calls_cycle test only covers the
cycle() code path in the _make_power_cycle method, but the fallback branch that
uses off() followed by sleep(2) followed by on() remains untested. Add a new
test case that mocks the power object to trigger the fallback path (either by
not providing a cycle method or having it unavailable), then verify that the
fallback sequence of off(), sleep(), and on() method calls is executed properly
when the cycle function is invoked through client.portal.call().
In
`@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/console_test.py`:
- Around line 44-45: Replace the three instances of time.sleep(0.1) calls with
deterministic readiness signaling instead of relying on fixed delays to assume
console readiness. For each location where time.sleep(0.1) precedes an os.write
operation, implement a proper synchronization mechanism such as using select,
poll, or event-based signaling to confirm the file descriptor is actually ready
for writing before proceeding, eliminating the intermittent CI flakes caused by
timing assumptions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cb30cdcc-eb35-42ef-8a00-b909cd4dc09f
📒 Files selected for processing (2)
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.pypython/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/console_test.py
Replace duck-typing power discovery with conservative label-based detection to prevent false positives (GPIO pins, storage mux drivers) and handle multi-power setups safely. Changes: - Add power_control_ref config field for explicit device selection - Add power_control_method config field for custom sequences (default: ["cycle"]) - Implement allowlist: only PowerClient/VirtualPowerClient auto-discovered - Add ambiguity detection: warn and disable when multiple candidates found - Support method sequences: ["off", "sleep:2", "on"], ["reset"], etc. - Support disable via empty list: power_control_method: [] - Pass config to client via extra_labels() following DbusNetwork pattern Addresses reviewer feedback on PR jumpstarter-dev#791 about auto-discovery risks in multi-power environments. Feature remains enabled by default for simple setups but disables itself at first sign of trouble. Tests: 71/71 pass, lint and type checks clean Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py (1)
13-23: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winTest
VirtualPowerClientdiscovery.This test covers
PowerClientonly.KNOWN_POWER_CLIENTSalso acceptsVirtualPowerClient. Add a parameterized case for"jumpstarter_driver_power.client.VirtualPowerClient"so a regression in that supported label is detected.As per coding guidelines,
python/**/*_test.pymust “Provide comprehensive package test coverage.”🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py` around lines 13 - 23, Extend test_find_power_client_auto_discover to cover both supported client labels by parameterizing the test and including "jumpstarter_driver_power.client.VirtualPowerClient" alongside the existing PowerClient label. Keep the discovery setup and assertion unchanged for each parameterized case.Source: Coding guidelines
🧹 Nitpick comments (1)
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/driver.py (1)
103-103: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAlign the annotation with the accepted input.
Line [103] declares
power_control_methodaslist[str], but Lines [112-115] accept astr. A typed caller cannot pass a supported string value without a type-checking error. Use a union at the input boundary, then normalize the stored value tolist[str].Also applies to: 112-115
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/driver.py` at line 103, Update the power_control_method annotation and initialization in the driver configuration to accept both str and list[str] at the input boundary, matching the handling in lines 112-115. Normalize a supplied string to a one-element list so the stored value remains list[str], while preserving the existing default and list behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client.py`:
- Around line 188-204: Update the power-control setup around _cycle to validate
every step before enabling the hotkey: require non-sleep operations on
power_client to be callable, parse each sleep: delay during construction, and
catch invalid values by logging a warning and returning None. Preserve valid
operation ordering, and add tests covering a non-callable attribute and an
invalid sleep value.
---
Outside diff comments:
In
`@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.py`:
- Around line 13-23: Extend test_find_power_client_auto_discover to cover both
supported client labels by parameterizing the test and including
"jumpstarter_driver_power.client.VirtualPowerClient" alongside the existing
PowerClient label. Keep the discovery setup and assertion unchanged for each
parameterized case.
---
Nitpick comments:
In
`@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/driver.py`:
- Line 103: Update the power_control_method annotation and initialization in the
driver configuration to accept both str and list[str] at the input boundary,
matching the handling in lines 112-115. Normalize a supplied string to a
one-element list so the stored value remains list[str], while preserving the
existing default and list behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: eeb0681c-6d5e-451d-b312-e5f4f45568d6
📒 Files selected for processing (3)
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client.pypython/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/client_test.pypython/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/driver.py
Replace duck-typing power discovery with conservative label-based detection to prevent false positives (GPIO pins, storage mux drivers) and handle multi-power setups safely. Changes: - Add power_control_ref config field for explicit device selection - Add power_control_method config field for custom sequences (default: ["cycle"]) - Implement allowlist: only PowerClient/VirtualPowerClient auto-discovered - Add ambiguity detection: warn and disable when multiple candidates found - Support method sequences: ["off", "sleep:2", "on"], ["reset"], etc. - Support disable via empty list [], empty string "", or null - Pass config to client via extra_labels() following DbusNetwork pattern - Pre-validate callable methods and parse sleep values at construction - Fix type annotation: power_control_method accepts list[str] | str | None - Add field docstrings and update README with config table and hotkey docs Addresses reviewer feedback on PR jumpstarter-dev#791 about auto-discovery risks in multi-power environments and CodeRabbit findings on validation timing. Feature remains enabled by default for simple setups but disables itself at first sign of trouble. Tests: 74/74 pass, coverage improved from 78% to above 80% threshold Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
ae02650 to
ea0e41a
Compare
- Add on_power_cycle callback to Console; Ctrl-] x3 triggers it - Add root back-reference to DriverClient, stamped during tree construction - Auto-discover power client from DUT siblings in PySerialClient - Prefer cycle() when available, fall back to off()+on() Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Add ConsoleStreamDrop exception to signal a dropped serial stream - Add retry loop in start_console to reconnect on stream drop - Use object.__setattr__ to stamp root back-reference without polluting pydantic schema - Remove root field from DriverClient; it is now a dynamic attribute Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Ctrl-B x3 exits cleanly - Ctrl-] x3 triggers on_power_cycle and console stays alive - Ctrl-] x3 without a power client does nothing Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Replace duck-typing power discovery with conservative label-based detection to prevent false positives (GPIO pins, storage mux drivers) and handle multi-power setups safely. Changes: - Add power_control_ref config field for explicit device selection - Add power_control_method config field for custom sequences (default: ["cycle"]) - Implement allowlist: only PowerClient/VirtualPowerClient auto-discovered - Add ambiguity detection: warn and disable when multiple candidates found - Support method sequences: ["off", "sleep:2", "on"], ["reset"], etc. - Support disable via empty list [], empty string "", or null - Pass config to client via extra_labels() following DbusNetwork pattern - Pre-validate callable methods and parse sleep values at construction - Fix type annotation: power_control_method accepts list[str] | str | None - Add field docstrings and update README with config table and hotkey docs Addresses reviewer feedback on PR jumpstarter-dev#791 about auto-discovery risks in multi-power environments and CodeRabbit findings on validation timing. Feature remains enabled by default for simple setups but disables itself at first sign of trouble. Tests: 74/74 pass, coverage improved from 78% to above 80% threshold Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fixes two power auto-discovery bugs: 1. **Proxy dedup**: When a Proxy driver delegates to a power client (e.g., Proxy(ref="qemu.power")), the same driver instance appears twice in the client tree — once via proxy, once via direct parent. This triggered false "Multiple power drivers found" ambiguity. Fixed by tracking UUIDs in `_collect_power_clients` to skip already-seen drivers. 2. **Allowlist expansion**: RideSXPowerClient, NoyitoPowerClient, and SNMPServerClient all extend PowerClient but weren't in the allowlist, causing auto-discovery to silently find nothing on those targets. Added all three to `KNOWN_POWER_CLIENTS`. Also adds user feedback: when Ctrl-] x3 is pressed without a power driver, log a warning instead of silently doing nothing. Co-Authored-By: Claude Opus 4.6 <[email protected]>
ea0e41a to
f807a7f
Compare
|
@mangelajo @evakhoni whats the plan with this one? It seems quite old. Do we want to merge or close this one? |
good question. I was away for quite some time on a vacation, but before I left it was awaiting a final review more or less 🤔 edit: solved the merge conflict so in case we decide it's a merger - should be ready to go |
Merged changes from upstream/main, resolving conflicts in pyserial driver:
1. **driver.py**: Added upstream's `always_on` field alongside power control
fields (`power_control_ref`, `power_control_method`)
2. **client.py**:
- Merged imports (logging, os, stat)
- Integrated `--observe` flag for read-only console mode with power cycle
logic. Power cycle hotkey is disabled in observe mode (passive observer
shouldn't control power)
- Preserved retry loop for both modes (benefits active users after power
cycle and observers after connection drops)
3. **console.py**:
- Console now accepts both `observe` and `on_power_cycle` parameters
- Merged observe mode logic (uses "observe" vs "connect" method, passes
None for stream when observe=True) with exception handling for
ConsoleStreamDrop and EndOfStream
- stdin handler resets ctrl_bracket_count AND checks stream is not None
4. **README.md**: Added documentation for all new parameters (`power_control_ref`,
`power_control_method`, `always_on`)
All tests pass (83 tests).
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
f2c78f4 to
d5a7610
Compare
|
@evakhoni @mangelajo i thought about this a bit, perhaps we can simplify this if we opt-in when the power driver is referenced from serial, then we don't need auto discovery and the pyserial code can be simplified to something like: @base.command()
@click.option("--observe", is_flag=True, default=False, help="Watch-only mode (read-only)")
def console(observe):
"""Start serial port console"""
power = None if observe else self.children.get("power")
if power is not None and not callable(getattr(power, "cycle", None)):
click.echo("Warning: 'power' child has no cycle() method, power hotkey disabled", err=True)
power = None
hint = "exit with CTRL+B x 3 times"
if power is not None:
hint += ", power cycle with CTRL+] x 3 times"
click.echo(f"\nStarting serial console{' in observe mode' if observe else ''} ... {hint}\n")
Console(serial_client=self, observe=observe, power=power).run() |
Address review feedback from bennyz on PR jumpstarter-dev#791: 1. **Fix retry counter accumulation** (client.py): - Reset retry counter after healthy sessions (≥5s duration) - Reduce max retries from 30 to 10 (sufficient for rapid failures) - Add named constants for clarity (SUCCESSFUL_SESSION_THRESHOLD, MAX_RAPID_FAILURES) 2. **Extract HotkeyDetector class** (console.py): - Reusable class for detecting repeated key sequences - Simplifies stdin handling logic - Behavior change: Ctrl-] bytes now forwarded to serial when no power client available (previously swallowed with warning) 3. **Fix critical stream error handling** (console.py): - Add STREAM_ERRORS constant (EndOfStream, BrokenResourceError, ClosedResourceError) - Suppress send() errors in __read_stdin (silent drop during power cycle) - Map all stream errors to ConsoleStreamDrop in __serial_to_stdout - Fixes crash when typing during power cycle USB re-enumeration (2-5s window) - Power cycle now survives without tearing down console session 4. **Add comprehensive tests** (console_test.py): - test_send_failure_does_not_kill_console: verify resilience to send() failures - test_receive_failure_raises_stream_drop: verify receive() error routing - 6 HotkeyDetector unit tests: three presses, reset on unrelated byte, alternating keys, byte outside keys, counter reset after hit All 90 tests pass. Linter clean. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@bennyz hmm.. sounds a bit limiting imho. hardcoding the power client to be named "power" in order for the hotkey to appear sounds like something the users gonna miss easily. |
| Full teardown happens at session end via shutdown(). | ||
|
|
||
| Deliberately does not chain to super().close(): that would close child | ||
| drivers (e.g. a `power` ref, switching the DUT off) on a remote kick. | ||
| Full teardown, children included, happens at session end via shutdown(). | ||
| """ | ||
| if self._fanout is not None: |
There was a problem hiding this comment.
This is incorrect, closing the power driver does not switch off.
Please restore fanout.py
There was a problem hiding this comment.
ah even opus was wrong here.. it mentioned that FanOutStreamMixin.close() kicks the clients and then calls Driver.close(), which calls close() on every child, which in case of qemu/renode can call QemuPower.close() or RenodePower.close() which would power them off, but turns out our hotkey is unaffected at all, and it's only a theoretical path if called programmatically. removing this one 🆗
There was a problem hiding this comment.
I think it's right, but that's more like a bug on those drivers that we will need to tackle separately.
There was a problem hiding this comment.
Anyway, this cannot be triggered in production: The hotkey and normal console exit never call the exporter's close(). serial_client.close() only closes local streams, and no production caller of serial_client.call("close") was found. It would require an explicit remote call from custom code.
There was a problem hiding this comment.
yeah that's my impression as well. the issue exist, but it doesn't trigger by the hotkey so it's out of scope of this pr I guess. I wonder should I open an issue about it wdyt?
Per review, the console owns the Ctrl-] x3 hotkey: Console takes the power client (power_control) and runs its cycle() in a worker thread, so the public dut_power_cycle() and the client-side hook are removed. Also fix opening the console when the `power` child's client is unavailable (not installed or rejected by the allow list): the child is then a StubDriverClient whose attribute lookup raises ImportError, which getattr(..., None) does not swallow. Treat it as no usable power child. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Per review, revert the kick change from 12c3280: the power hotkey never calls close() on the serial driver, so a power child is only closed through a direct remote close() call, which nothing in the product makes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mangelajo
left a comment
There was a problem hiding this comment.
a couple of extra changes, we can just use PowerInterface there.
Per review, type the console's power control as PowerClient instead of a local Protocol, make jumpstarter-driver-power a runtime dependency of pyserial, and reduce _power_child() to an isinstance check. A power child that is unavailable (StubDriverClient) or not a PowerClient still just disables the hotkey. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The power-cycle thread assertion compared against the console thread instead of the event loop's thread, so it could not catch cycle() running on the loop. Compare against the loop thread, and wait for the console to attach (raw mode set) instead of sleeping before sending keys. Drop comments that described the PR's earlier states or restated the code, and rename the test helpers that referred to them. Note in the README that qemu's hotkey wiring does not apply in sidecar mode. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
@mangelajo ok, done that, and a little cleanup, and have tested locally on qemu. all seems fine - I guess it's ready now. |
Summary
powerchild (typically aref:to the exporter's power driver) when its client is aPowerClient, and callscycle()— so any power driver works with no exporter-side configconsole.py:Consoletakes thePowerClient(power_control) and runs itscycle()in a worker thread, so a blocking cycle doesn't stall the console's event loop; scripts can callclient.children["power"].cycle()directlyjumpstarter-driver-poweris now a runtime dependency ofjumpstarter-driver-pyserial(it was dev-only)powerchild, so the hotkey works there out of the box (qemu: except in sidecar mode)powerchild, or the child isn't aPowerClient(including a client that is unavailable — not installed or rejected by the allow list, so it is aStubDriverClient), and in observe mode; none of these prevent the console from openingExample
Test plan
jumpstarter-driver-pyserial(plus 1 strict xfail for Serial console stream is torn down when input is sent while the serial device is reconnecting #1231): power child resolution incl.ref:wiring and the realPowerClientcycling the power driver, a power child that isn't aPowerClientor is unavailable (stub) not breaking the console, the hotkey runningcycle()on a worker thread and surviving a failing cycle, console banner, observe modepowerchild is the driver's own power instance (dutlink's skips without hardware)[disconnected]/[reconnected]markers)