Repository navigation
feat(python): plumb the workflow lease through the PyO3 facade - #1879
Merged
Merged
Conversation
The daemon admits deploy and serial attach on an exclusive device lease (#1869/#1871/#1873/#1877), but the PyO3 surface never carried the lease id, so a Python workflow that took a lease could not deploy, let alone attach its own monitor: its own request looked like a foreign client. - OpRequest gains lease_id (omitted when None) and lease_wait_ms (omitted at 0), so DaemonConnection.deploy/deploy_result and their async counterparts accept lease_id=None, lease_wait_ms=0. Defaults keep the historical fail-fast behaviour and byte-identical JSON. - ClientMessage::Attach gains lease_id, SessionConfig carries it, and SerialMonitor/AsyncSerialMonitor accept lease_id=None. The attach frame is built in one place (serial_session::attach_message) so the config-to-frame mapping is testable without a daemon. - Contract pin (AT-P9) and the pyo3-bindings doc track the new kwarg. Tests: new deploy_request forwarding (sync + async), OpRequest lease serialization, and attach-frame mapping; behavioural RED first (stub the forwarding -> 3 failed) then green. fbuild-python --lib 68 passed; python_facades --ignored 22 passed (at_p7 is a pre-existing flake, 2/5 at origin/main baseline); clippy rc 0; fmt rc 0; dylint rc 0. Refs #1864
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
Fifth slice of #1864 — Python facade lease plumbing (the last code criterion).
Why
The daemon now admits every mutating device path on an exclusive workflow
lease (
#1869deploy,#1871serial write/RPC,#1873bounded wait,#1877renumber follow). The PyO3 surface never carried the lease id, so aPython workflow that held the lease still looked like a foreign client to
its own deploy, and
SerialMonitorcould not attach the board it reserved.What
OpRequestgainslease_id(omitted whenNone) andlease_wait_ms(omitted at0, matching the daemon'sserde(default)).DaemonConnection.deploy/deploy_resultand the async counterpartsaccept
lease_id=None, lease_wait_ms=0, so defaults keep the historicalfail-fast admission and the JSON stays byte-identical for existing callers.
ClientMessage::Attachgainslease_id,SessionConfigcarries it, andSerialMonitor(lease_id=...)/AsyncSerialMonitor(lease_id=...)present it. Frame construction moved toserial_session::attach_message(sibling module, keepsserial_session.rsat the 1000-LOC gate) so the config-to-frame mapping is testable without a
daemon.
lease_idfor both facades;docs/architecture/pyo3-bindings.mdandpython/fbuild/api/README.mddocument the kwarg.
A Python workflow can now: acquire the lease,
deploy(lease_id=...),SerialMonitor(port, lease_id=...), validate, release — with norelease/reacquire gap.
Tests (real output)
deploy_request_forwards_lease_identity(sync),async_deploy_request_forwards_lease_identity,op_request_omits_lease_fields_by_default, andattach_frame_forwards_configured_lease.lease_id: None,lease_wait_ms: 0) and the attach mapping gives1 passed; 3 failedwithleft: None / right: Some("lease-abc"); restored->
4 passed; 0 failed.soldr cargo test -p fbuild-python --lib— 68 passed / 0 failed.python_facades -- --ignored(embedded CPython) — 22 passed;cases::at_p7_async_cancel_read_lines_repeatedlyis a pre-existing flake(2 of 5 runs fail at the same commit without this diff, stashed and
reran), unrelated to lease plumbing.
soldr cargo clippy -p fbuild-python --all-targetsrc 0,cargo fmt --all -- --checkrc 0,python -m ci.run_dylint --package fbuild-pythonrc 0.Remaining on #1864 after this: criterion 6 (two real checkouts taking turns on
one board) — needs a board slot not in use for FastLED/FastLED#5001.