GUI: tidied up automation panel and made it a little prettier. added timing to events
This commit is contained in:
1 parent
e396b7e6a0
commit
c60db6798a
1 file changed
+24
-49
@@ -42,15 +42,21 @@ class AutomationProgressWidget(QWidget):
|
||||
|
||||
def _setup_ui(self) -> None:
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(8, 8, 8, 8)
|
||||
layout.setSpacing(6)
|
||||
layout.setContentsMargins(10, 10, 10, 10)
|
||||
layout.setSpacing(10)
|
||||
|
||||
self._title_label = QLabel("Automation progress")
|
||||
self._title_label.setStyleSheet("font-size: 14px; font-weight: bold;")
|
||||
self._title_label.setStyleSheet(
|
||||
"font-size: 16px; font-weight: 700; color: #1F2937; margin-bottom: 2px;"
|
||||
)
|
||||
layout.addWidget(self._title_label)
|
||||
|
||||
self._stats_label = QLabel()
|
||||
self._stats_label.setStyleSheet("color: #555; font-size: 11px; margin-bottom: 4px;")
|
||||
self._stats_label.setStyleSheet(
|
||||
"color: #374151; font-size: 13px; "
|
||||
"background-color: #F8FAFC; border: 1px solid #E2E8F0; "
|
||||
"border-radius: 8px; padding: 10px;"
|
||||
)
|
||||
self._stats_label.setWordWrap(True)
|
||||
layout.addWidget(self._stats_label)
|
||||
|
||||
@@ -100,7 +106,7 @@ class AutomationProgressWidget(QWidget):
|
||||
WorkflowStateKind.LOOP_CENTRE: "Center",
|
||||
WorkflowStateKind.RASTER: "Raster",
|
||||
WorkflowStateKind.DATA_COLLECTION: "Collect",
|
||||
WorkflowStateKind.FINAL: "Paused/Finished",
|
||||
WorkflowStateKind.FINAL: "Status",
|
||||
}.get(step, str(step.value))
|
||||
|
||||
@staticmethod
|
||||
@@ -116,19 +122,22 @@ class AutomationProgressWidget(QWidget):
|
||||
|
||||
@staticmethod
|
||||
def _style_for_status(status: StepStatus) -> str:
|
||||
base = "padding: 6px; border-radius: 4px;"
|
||||
base = (
|
||||
"padding: 10px 12px; border-radius: 10px; "
|
||||
"font-size: 14px; border: 1px solid transparent;"
|
||||
)
|
||||
|
||||
if status == StepStatus.SUCCESS:
|
||||
return base + " background-color: #E8F5E9; color: #1B5E20;"
|
||||
return base + " background-color: #ECFDF3; color: #166534; border-color: #A7F3D0;"
|
||||
if status == StepStatus.RUNNING:
|
||||
return base + " background-color: #E3F2FD; color: #0D47A1; font-weight: bold;"
|
||||
return base + " background-color: #EFF6FF; color: #1D4ED8; font-weight: 700; border-color: #BFDBFE;"
|
||||
if status == StepStatus.FAILED:
|
||||
return base + " background-color: #FFEBEE; color: #B71C1C; font-weight: bold;"
|
||||
return base + " background-color: #FEF2F2; color: #B91C1C; font-weight: 700; border-color: #FECACA;"
|
||||
if status == StepStatus.PAUSED:
|
||||
return base + " background-color: #FFF3E0; color: #E65100; font-weight: bold;"
|
||||
return base + " background-color: #FFF7ED; color: #C2410C; font-weight: 700; border-color: #FED7AA;"
|
||||
if status == StepStatus.SKIPPED:
|
||||
return base + " background-color: #F5F5F5; color: #616161;"
|
||||
return base + " background-color: #F7F7F7; color: #757575;"
|
||||
return base + " background-color: #F8FAFC; color: #475569; border-color: #E2E8F0;"
|
||||
return base + " background-color: #F8FAFC; color: #64748B; border-color: #E2E8F0;"
|
||||
|
||||
@staticmethod
|
||||
def _format_duration(seconds: float | None) -> str:
|
||||
@@ -156,16 +165,6 @@ class AutomationProgressWidget(QWidget):
|
||||
for step in progress.steps
|
||||
)
|
||||
|
||||
def _current_sample_elapsed_seconds(self, progress: AutomationProgress) -> float:
|
||||
started_times = [
|
||||
step.started_at
|
||||
for step in progress.steps
|
||||
if step.started_at is not None and step.step != WorkflowStateKind.FINAL
|
||||
]
|
||||
if not started_times:
|
||||
return 0.0
|
||||
return max(0.0, time.time() - min(started_times))
|
||||
|
||||
def _has_active_sample(self, progress: AutomationProgress) -> bool:
|
||||
if progress.finished:
|
||||
return False
|
||||
@@ -199,7 +198,6 @@ class AutomationProgressWidget(QWidget):
|
||||
|
||||
if self._is_paused:
|
||||
self._refresh_timer.stop()
|
||||
progress.current_step = "Paused"
|
||||
if final_step is not None:
|
||||
final_step.status = StepStatus.PAUSED
|
||||
final_step.message = "Automation paused"
|
||||
@@ -232,7 +230,6 @@ class AutomationProgressWidget(QWidget):
|
||||
measured_avg_seconds = progress.avg_time_per_sample if progress.avg_time_per_sample > 0 else None
|
||||
displayed_avg_seconds = measured_avg_seconds or self.DEFAULT_SAMPLE_ESTIMATE_S
|
||||
|
||||
current_step = "Paused" if self._is_paused else (progress.current_step or "Idle")
|
||||
current_sample = progress.current_sample_name or "None"
|
||||
samples_left = (
|
||||
self._gui_samples_in_queue
|
||||
@@ -240,27 +237,17 @@ class AutomationProgressWidget(QWidget):
|
||||
else max(0, int(progress.samples_in_queue or 0))
|
||||
)
|
||||
|
||||
has_active_sample = self._has_active_sample(progress) and not self._is_paused
|
||||
current_sample_elapsed = self._current_sample_elapsed_seconds(progress)
|
||||
|
||||
if progress.finished or not has_active_sample:
|
||||
current_sample_remaining = 0.0
|
||||
if progress.finished or self._is_paused or not self._has_active_sample(progress):
|
||||
queue_remaining = displayed_avg_seconds * samples_left
|
||||
else:
|
||||
current_sample_remaining = max(0.0, displayed_avg_seconds - current_sample_elapsed)
|
||||
if samples_left == 0:
|
||||
queue_remaining = current_sample_remaining
|
||||
else:
|
||||
queue_remaining = current_sample_remaining + (displayed_avg_seconds * samples_left)
|
||||
queue_remaining = displayed_avg_seconds * max(0, samples_left)
|
||||
|
||||
eta_clock = time.time() + queue_remaining if queue_remaining > 0 else None
|
||||
|
||||
stats_lines = [
|
||||
f"<b>Current sample:</b> {current_sample}",
|
||||
f"<b>Current step:</b> {current_step}",
|
||||
f"<b>Samples left:</b> {samples_left}",
|
||||
f"<b>Avg sample time:</b> {self._format_duration(displayed_avg_seconds)}",
|
||||
f"<b>This sample ETA:</b> {self._format_duration(current_sample_remaining)}",
|
||||
f"<b>Queue remaining:</b> {self._format_duration(queue_remaining)}",
|
||||
f"<b>Done by:</b> {self._format_eta_timestamp(eta_clock)}",
|
||||
]
|
||||
@@ -286,16 +273,4 @@ class AutomationProgressWidget(QWidget):
|
||||
label.setStyleSheet(self._style_for_status(step_state.status))
|
||||
|
||||
if self._title_label is not None:
|
||||
if self._is_paused:
|
||||
self._title_label.setText("Automation progress — Paused")
|
||||
elif progress.finished:
|
||||
if progress.success is True:
|
||||
self._title_label.setText("Automation progress — Finished")
|
||||
elif progress.success is False:
|
||||
self._title_label.setText("Automation progress — Finished with error")
|
||||
else:
|
||||
self._title_label.setText("Automation progress")
|
||||
elif progress.current_step:
|
||||
self._title_label.setText(f"Automation progress — {progress.current_step}")
|
||||
else:
|
||||
self._title_label.setText("Automation progress")
|
||||
self._title_label.setText("Automation progress")
|
||||
Reference in new issue
Block a user