diff --git a/cluster4npu_ui/core/functions/InferencePipeline.py b/cluster4npu_ui/core/functions/InferencePipeline.py index 4a9d639..ead58f2 100644 --- a/cluster4npu_ui/core/functions/InferencePipeline.py +++ b/cluster4npu_ui/core/functions/InferencePipeline.py @@ -227,7 +227,8 @@ class PipelineStage: break 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") inference_result = {'probability': 0.0, 'result': 'No Result'} diff --git a/cluster4npu_ui/ui/dialogs/deployment.py b/cluster4npu_ui/ui/dialogs/deployment.py index 242e063..c79e2f8 100644 --- a/cluster4npu_ui/ui/dialogs/deployment.py +++ b/cluster4npu_ui/ui/dialogs/deployment.py @@ -64,7 +64,7 @@ class DeploymentWorker(QThread): deployment_started = pyqtSignal() deployment_completed = pyqtSignal(bool, str) # success, message 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]): super().__init__() @@ -136,6 +136,10 @@ class DeploymentWorker(QThread): 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") + # Keep running until stop is requested + while not self.should_stop: + self.msleep(100) # Sleep for 100ms and check again + except Exception as e: self.error_occurred.emit(f"Pipeline deployment failed: {str(e)}") @@ -533,19 +537,29 @@ Stage Configurations: if reply == QMessageBox.Yes: self.deployment_log.append("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.setVisible(False) - self.deploy_button.setEnabled(True) - self.close_button.setText("Close") - self.progress_bar.setVisible(False) - self.deployment_log.append("Inference stopped.") - self.status_label.setText("Inference stopped") - self.dongle_status.setText("Pipeline stopped") + self.deployment_worker.stop() + + # 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): """Update deployment progress."""