Skip to content

feat(monet): bump to v0.7.17 + Disconnect button on the Monet tab - #72

Merged
Heerpa merged 2 commits into
developfrom
feature/monet-update-and-disconnect
Dec 2, 2026
Merged

Heerpa merged 2 commits into
developfrom
feature/monet-update-and-disconnect

Conversation

@Heerpa

@Heerpa Heerpa commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Two related changes.

1. monet dependency v0.6.13 → v0.7.17

monet moved on since we pinned it. I verified the monet API PycroFlow actually uses is unchanged against the current version:

  • monet.CONFIGS / monet.PROTOCOLS / monet.LASER_TAG
  • monet.control.IlluminationLaserControl(config, auto_enable_lasers=…) + load_calibration_database()
  • monet.gui.MonetWidget / MonetMainWindow / shutdown() / connected
  • monet.io.check_server_auth

monet's own pins stay compatible with PycroFlow's: PyQt6<7 (⊇ our <6.12) and picasso-registry @ v0.1.0 (same as ours). CI is unaffected — the hosted CI installs .[dev,gui], not [hardware] (where the monet git dep lives), and monet is mocked; the bump only affects lab installs.

2. Disconnect monet from the Monet tab

Problem: if you connect monet (in the Monet tab) to check the sample live before an acquisition, you then can't start an experiment — monet holds the laser COM ports — and monet's embedded widget has a Connect but no Disconnect, so you're stuck.

Fix: the Monet tab gains a "Disconnect monet" button that calls MonetWidget.shutdown() (disables the lasers and releases the serial ports / SDK sessions), enabled once monet reports it has connected. Starting a run also releases monet automatically (set_run_lock), but disconnecting first is the reliable path — the auto-release fires as the run is already starting, so it can race the orchestrator opening the lasers. The tab's explainer now says to disconnect before a run.

Tests

  • test_disconnect_button_releases_monet: button disabled until monet's connected fires; clicking it calls shutdown() and re-disables.
  • test_run_lock_releases_monet: starting a run releases monet (shutdown) and greys its controls.

Full suite passes bar the known monet dev-container flake (test_placeholder_when_monet_absent, green in CI).

🤖 Generated with Claude Code

Heerpa and others added 2 commits December 2, 2026 15:43
monet moved on since we pinned it; update the [hardware] pin v0.6.13 -> v0.7.17.
The monet API PycroFlow uses is unchanged (monet.CONFIGS/PROTOCOLS,
control.IlluminationLaserControl(config, auto_enable_lasers=...), gui.MonetWidget
+ shutdown, io.check_server_auth), and monet's PyQt6<7 / picasso-registry@v0.1.0
pins stay compatible. CI never installs monet (mocked; [hardware] not installed),
so the bump only affects lab installs.

Also fix being stuck after a live monet check: monet's embedded widget has a
Connect but no Disconnect, so once you connected monet to view the sample you
could neither start an experiment (monet held the laser ports) nor release it.
The Monet tab gains a "Disconnect monet" button (calls MonetWidget.shutdown(),
which releases the lasers/serial ports), enabled once monet reports connected.
Starting a run also releases monet (set_run_lock), but disconnecting first is
the reliable path since the auto-release fires as the run is already starting.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Only release monet on run-lock when it is actually connected. `set_run_lock`
  used to call `disconnect_monet()` → monet `shutdown()` on every run start;
  `shutdown()` joins monet's calibration worker, so with a calibration running
  that could block the GUI thread for up to 5 s right as the run starts (and it
  was pointless work when monet was never connected). Gate it on
  `self._monet_connected`.
- Log (instead of silently swallowing) a failure to wire monet's `connected`
  signal, so a never-enabling Disconnect button is diagnosable.

Reviewed and left as-is: monet's own "Connected" banner stays stale after a
release (a monet-side display concern — PycroFlow's Disconnect button is the
authoritative PycroFlow-side indicator), and the best-effort auto-release can
still race a run start (disconnecting from the tab first is the reliable path,
as documented). Reconnect after disconnect works (monet rebuilds its pc), and
the `connected` signal is emitted on the GUI thread (slot wiring is safe) — both
verified against the real monet source.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Heerpa

Heerpa commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Deep code review (monet-tab correctness + full monet API-compat sweep) → fixed in 88077b1

monet v0.7.17 API compatibility — fully verified against the real monet source. All ~25 symbols PycroFlow uses (CONFIGS/PROTOCOLS/LASER_TAG, control.IlluminationLaserControl(config, auto_enable_lasers=…) + instrument .laser/.lasers/.attenuator/.beampath/.load_calibration_database, io.check_server_auth, gui.MonetWidget/shutdown/connected/_scope_combo) are present and compatible. The one API change (a new auto_home param on IlluminationLaserControl.__init__) is harmless because PycroFlow passes auto_enable_lasers as a keyword.

Fixed:

  • GUI could freeze up to 5 s at run start. set_run_lock(True) always called disconnect_monet() → monet shutdown(), which joins monet's calibration worker — so with a calibration running it blocked the GUI thread (and did pointless work when monet was never connected). Now gated on self._monet_connected, so the join only happens when monet actually holds the hardware (a legitimate release).
  • Silent dead button. The connected-signal wiring was except: pass; a binding failure would leave the Disconnect button permanently disabled with no clue. Now logged.

Verified safe (no change):

  • Reconnect after disconnect works — shutdown() only _pc.disconnect()s (idempotent); monet's connect_microscope rebuilds a fresh pc and re-fires connected, re-enabling the button.
  • Signal threading is safe — monet emits connected on the GUI thread (inside _on_connected), so the slot runs synchronously on the GUI thread.
  • Double-shutdown on app-close after a manual disconnect is idempotent (monet contract).

Left as-is (monet-side / inherent): monet's own "Connected" banner stays stale after a release (a monet display concern — PycroFlow's Disconnect button is the authoritative PycroFlow-side indicator); the best-effort auto-release can still race a run start, which is why disconnecting from the tab first is the documented reliable path.

New test: a run start does NOT call shutdown() when monet was never connected. Full suite 1097 passed (only the known monet dev-container flake).

@Heerpa
Heerpa merged commit 8971136 into develop Dec 2, 2026
6 checks passed
@Heerpa
Heerpa deleted the feature/monet-update-and-disconnect branch December 2, 2026 16:39
This was referenced Dec 2, 2026
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