automate_observation: split run() into process_device() and print_sum… - #37
Merged
Merged
Conversation
…mary() The per-device workflow lived inline in run(), with its outcome spread across three shared sets and a `continue` on every failure. Each recent feature (--serial, --events, prompts) added branches to that one loop, it could only be tested end to end through main(), and the scattered bookkeeping made status bugs easy. Split it, with no behaviour change: - process_device() observes one device and returns a DeviceResult (status, results_dir, error); print_summary() logs the final lines and returns the run_finished summary. - RunState carries pre-fetch state across devices; classify_device() holds the status rules and replaces device_status(). Log text, events and exit codes are unchanged. Moved lines now show _observe_device or print_summary instead of run as the function name in the log prefix. One edge case: if two connected devices share a serial, the summary line shows the last one's outcome (the exit code still reflects both). Test: - pytest uraniborg/scripts/python/tests/: 156 passed (11 new, calling the new functions directly; test_device_status replaced by test_classify_device; other existing tests unmodified). - Live on an Android 14 emulator, before vs after: identical logs (apart from function names) and events (apart from timestamps). Change-Id: Ib1d454ea5586cf110ae6cbbcd8ca1cda02907d9b
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.
…mary()
The per-device workflow lived inline in run(), with its outcome spread across three shared sets and a
continueon every failure. Each recent feature (--serial, --events, prompts) added branches to that one loop, it could only be tested end to end through main(), and the scattered bookkeeping made status bugs easy.Split it, with no behaviour change:
Log text, events and exit codes are unchanged. Moved lines now show _observe_device or print_summary instead of run as the function name in the log prefix. One edge case: if two connected devices share a serial, the summary line shows the last one's outcome (the exit code still reflects both).
Test:
Change-Id: Ib1d454ea5586cf110ae6cbbcd8ca1cda02907d9b