Skip to content

Commit 1bbf2d3

Browse files
committed
Add queue error handling and status reporting
Introduces structured error tracking for queue-level errors in SweepQueue, including a QueueError dataclass. Adds an is_queued flag to ProgressState and ensures it is set/cleared appropriately as sweeps are added or removed from the queue. Implements comprehensive status() and clear_error() methods for queue state reporting and recovery. Improves error handling for sweep and callable execution, and adds a kill_all() method to fully reset the queue.
1 parent 654b271 commit 1bbf2d3

File tree

3 files changed

+366
-55
lines changed

3 files changed

+366
-55
lines changed

src/measureit/sweep/base_sweep.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ def update_progress(self) -> None:
604604
progress=progress_value,
605605
error_message=self.progressState.error_message,
606606
error_count=self.progressState.error_count,
607+
is_queued=self.progressState.is_queued,
607608
)
608609

609610
def mark_done(self) -> None:

src/measureit/sweep/progress.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,37 @@ class SweepState(Enum):
1717

1818
@dataclass
1919
class ProgressState:
20-
"""Lightweight container tracking sweep progress."""
20+
"""Lightweight container tracking sweep progress.
21+
22+
Attributes
23+
----------
24+
state : SweepState
25+
Current state of the sweep (READY, RAMPING, RUNNING, PAUSED, DONE, KILLED, ERROR).
26+
time_elapsed : float, optional
27+
Time elapsed since sweep started, in seconds.
28+
time_remaining : float, optional
29+
Estimated time remaining, in seconds.
30+
progress : float, optional
31+
Progress percentage (0.0 to 1.0).
32+
error_message : str, optional
33+
Error message if sweep ended in ERROR state.
34+
error_count : int
35+
Number of errors encountered during sweep execution.
36+
is_queued : bool
37+
True if the sweep is managed by a SweepQueue (either waiting in queue or
38+
currently running as part of queue execution). This allows external tools
39+
to distinguish between a sweep that is idle (not yet started) vs one that
40+
is part of a queue workflow. Set to True when appended to a SweepQueue,
41+
and False when the sweep completes, is killed, or is removed from the queue.
42+
"""
2143

2244
state: SweepState = SweepState.READY
2345
time_elapsed: Optional[float] = None
2446
time_remaining: Optional[float] = None
2547
progress: Optional[float] = None
2648
error_message: Optional[str] = None
2749
error_count: int = 0
50+
is_queued: bool = False
2851

2952

3053
__all__ = ["ProgressState", "SweepState"]

0 commit comments

Comments
 (0)