Skip to content

feat(server): pre-flight disk check for the TCP run commands - #659

Draft
hongquanli wants to merge 1 commit into
feat/large-acquisitions-pausefrom
feat/large-acquisitions-tcp-preflight
Draft

hongquanli wants to merge 1 commit into
feat/large-acquisitions-pausefrom
feat/large-acquisitions-tcp-preflight

Conversation

@hongquanli

Copy link
Copy Markdown
Contributor

Summary

Stacks on #648 (needs its large acquisition mode and YAML opt-in). Independent of #649 and #650; trial merges with both branch tips are conflict-free.

The "Not Enough Disk Space" check lived only in the two GUI acquisition widgets, so an acquisition started over TCP/MCP (run_acquisition, run_acquisition_from_yaml) was never checked: one that did not fit started anyway and filled the disk. A TCP client also never sees the dialog that offers large acquisition mode.

Behavior

Both commands now check the save disk after the controller is fully configured and before anything is created on disk (no stray experiment folder on refusal):

fits does not fit
large acquisition mode off starts as before refused: RuntimeError naming the opt-in
mode on (YAML acquisition.large_acquisition_mode: true, or the Large Acquisitions setting) starts starts; a warning is logged and the disk-space guard pauses the run while data is offloaded
skip_saving not checked (as in the GUI) not checked

This is a deliberate default-behavior change for TCP runs that do not fit (requested by @hongquanli): they used to start and fill the disk; the GUI has always refused them.

Implementation

  • control/core/disk_space.py: preflight_disk_check(controller, save_directory) returns a PreflightDiskCheck (required and available bytes, image count, fits, describe()). Qt-free. When the save folder does not exist yet, free space is measured on its nearest existing parent.
  • The GUI's check_space_available_with_error_dialog now uses the same function, so both paths share the estimate, the 1.03 safety factor and the message. The dialog flow is unchanged.
  • MicroscopeControlServer._refuse_if_acquisition_will_not_fit, called by both run commands; command docstrings (the MCP tool descriptions) and docs/mcp_integration.md describe it.

Tests

  • Helper: safety factor and fit, nearest-existing-parent measurement, message.
  • Server: a YAML run that does not fit is refused before start_new_experiment/run_acquisition and the error names the flag; YAML opt-in starts; global setting starts; skip_saving is not checked; a run that fits starts; the wells command is refused too. Verified these fail with the refusal neutralised.
  • A real simulated controller: the check works before the experiment folder exists and creates nothing.
  • Existing GUI pre-flight tests pass unchanged.

Not covered here: the fluidics protocol runner (widgets_fluidics/qt_imaging_port.py) also starts acquisitions from settings without this check.

🤖 Generated with Claude Code

The "Not Enough Disk Space" check lived only in the two GUI acquisition
widgets, so an acquisition started over TCP/MCP (run_acquisition,
run_acquisition_from_yaml) was never checked: one that did not fit
started anyway and filled the disk.

Both commands now run the same check, after the controller is fully
configured and before anything is created on disk. A run the save disk
cannot hold is refused with an error that names the opt-in
('large_acquisition_mode: true' under 'acquisition:' in the YAML, or the
Large Acquisitions setting); with the mode on it starts and the
disk-space guard pauses it while data is offloaded. Runs that save
nothing (skip_saving) are not checked, as in the GUI.

The decision is shared: control.core.disk_space.preflight_disk_check
(Qt-free; measures the nearest existing parent when the save folder does
not exist yet) now backs the GUI dialog too, so both paths use the same
estimate, safety factor and message.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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