fix: Complete array comparison fix and improve stop button functionality

- Fix remaining array comparison error in inference result validation
- Update PyQt signal signature for proper numpy array handling
- Improve DeploymentWorker to keep running after deployment
- Enhance stop button with non-blocking UI updates and better error handling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Masonmason 2025-07-17 10:03:59 +08:00
parent 183300472e
commit 0a70df4098
2 changed files with 27 additions and 12 deletions

View File

@ -227,7 +227,8 @@ class PipelineStage:
break break
time.sleep(0.01) time.sleep(0.01)
if not inference_result: # Check if inference_result is empty (handle both dict and tuple types)
if inference_result is None or (isinstance(inference_result, dict) and not inference_result):
print(f"[Stage {self.stage_id}] Warning: No inference result received") print(f"[Stage {self.stage_id}] Warning: No inference result received")
inference_result = {'probability': 0.0, 'result': 'No Result'} inference_result = {'probability': 0.0, 'result': 'No Result'}

View File

@ -64,7 +64,7 @@ class DeploymentWorker(QThread):
deployment_started = pyqtSignal() deployment_started = pyqtSignal()
deployment_completed = pyqtSignal(bool, str) # success, message deployment_completed = pyqtSignal(bool, str) # success, message
error_occurred = pyqtSignal(str) error_occurred = pyqtSignal(str)
frame_updated = pyqtSignal(object) # For live view frame_updated = pyqtSignal('PyQt_PyObject') # For live view
def __init__(self, pipeline_data: Dict[str, Any]): def __init__(self, pipeline_data: Dict[str, Any]):
super().__init__() super().__init__()
@ -136,6 +136,10 @@ class DeploymentWorker(QThread):
self.progress_updated.emit(100, "Pipeline deployed successfully!") self.progress_updated.emit(100, "Pipeline deployed successfully!")
self.deployment_completed.emit(True, f"Pipeline '{config.pipeline_name}' deployed with {len(config.stage_configs)} stages") self.deployment_completed.emit(True, f"Pipeline '{config.pipeline_name}' deployed with {len(config.stage_configs)} stages")
# Keep running until stop is requested
while not self.should_stop:
self.msleep(100) # Sleep for 100ms and check again
except Exception as e: except Exception as e:
self.error_occurred.emit(f"Pipeline deployment failed: {str(e)}") self.error_occurred.emit(f"Pipeline deployment failed: {str(e)}")
@ -533,19 +537,29 @@ Stage Configurations:
if reply == QMessageBox.Yes: if reply == QMessageBox.Yes:
self.deployment_log.append("Stopping inference...") self.deployment_log.append("Stopping inference...")
self.status_label.setText("Stopping inference...") self.status_label.setText("Stopping inference...")
self.deployment_worker.stop()
self.deployment_worker.wait(3000) # Wait up to 3 seconds
# Update UI # Disable stop button immediately to prevent multiple clicks
self.stop_button.setEnabled(False) self.stop_button.setEnabled(False)
self.stop_button.setVisible(False)
self.deploy_button.setEnabled(True)
self.close_button.setText("Close")
self.progress_bar.setVisible(False)
self.deployment_log.append("Inference stopped.") self.deployment_worker.stop()
self.status_label.setText("Inference stopped")
self.dongle_status.setText("Pipeline stopped") # Wait for worker to finish in a separate thread to avoid blocking UI
def wait_for_stop():
if self.deployment_worker.wait(5000): # Wait up to 5 seconds
self.deployment_log.append("Inference stopped successfully.")
else:
self.deployment_log.append("Warning: Inference may not have stopped cleanly.")
# Update UI on main thread
self.stop_button.setVisible(False)
self.deploy_button.setEnabled(True)
self.close_button.setText("Close")
self.progress_bar.setVisible(False)
self.status_label.setText("Inference stopped")
self.dongle_status.setText("Pipeline stopped")
import threading
threading.Thread(target=wait_for_stop, daemon=True).start()
def update_progress(self, value: int, message: str): def update_progress(self, value: int, message: str):
"""Update deployment progress.""" """Update deployment progress."""