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:
parent
183300472e
commit
0a70df4098
@ -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'}
|
||||||
|
|
||||||
|
|||||||
@ -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,20 +537,30 @@ 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.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.stop_button.setVisible(False)
|
||||||
self.deploy_button.setEnabled(True)
|
self.deploy_button.setEnabled(True)
|
||||||
self.close_button.setText("Close")
|
self.close_button.setText("Close")
|
||||||
self.progress_bar.setVisible(False)
|
self.progress_bar.setVisible(False)
|
||||||
|
|
||||||
self.deployment_log.append("Inference stopped.")
|
|
||||||
self.status_label.setText("Inference stopped")
|
self.status_label.setText("Inference stopped")
|
||||||
self.dongle_status.setText("Pipeline 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."""
|
||||||
self.progress_bar.setValue(value)
|
self.progress_bar.setValue(value)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user