alab_management.lab_reset module#

Force the lab back to an empty software state without restarting processes.

This is the dashboard “Release locks & tasks” action. It cancels every live task, dismisses user-input prompts, drops resource locks, releases devices, clears the mobile-robot queues, unlocks sample-position reservations, clears sample task ownership / in-transit flags (without wiping physical position / last_position), and closes open experiments.

It does not stop hardware that is already moving, and it does not drop Mongo.

exception LabNotIdleError(reasons)[source]#

Bases: RuntimeError

Raised when a lab-settings action requires an idle lab.

archive_experiments_to_completed(experiment_ids)[source]#

Copy each experiment into completed when configured. Returns how many archived.

Return type:

int

archive_terminal_experiments_missing_from_completed()[source]#

Archive COMPLETED/CANCELLED live experiments that are not yet in completed.

Return type:

int

clear_lab_occupancy()[source]#

Clear every sample’s current position; keep identity, last_position, history.

Requires an idle lab. Uses move_sample(..., None) so history gets a cleared event, matching per-slot Clear on Sample Positions.

Archives any terminal live experiments that are missing from completed, then prunes live docs that are already archived (never deletes without a completed copy).

Return type:

dict[str, int]

get_lab_idle_status()[source]#

Return whether the lab has no live work or position reservations.

Do not use /api/status alone — that endpoint only lists RUNNING experiments.

Return type:

dict[str, Any]

prune_archived_unplaced_from_live()[source]#

Delete live samples/tasks/experiments that are safely archived and unplaced.

Hard rule: never delete a live document unless the same _id exists in Alab(completed). Missing completed copies are skipped with a warning.

Return type:

dict[str, int]

reset_lab_software_state(*, settle_s=2.0)[source]#

Cancel everything the dashboard is waiting on so a new experiment can be submitted.

Physical sample occupancy (samples.position / last_position) is preserved. Only ephemeral ownership is cleared: task IDs, in-transit flags, and position locks. Closed experiments are archived to completed when configured, then unplaced archived docs may be pruned from live.

Return type:

dict[str, int]