From bcaa3cd0eaa3f91ed6852483f3f6f5b6a5c15b54 Mon Sep 17 00:00:00 2001 From: healthonrails Date: Tue, 26 Nov 2024 17:07:11 -0500 Subject: [PATCH] fix: handle TypeError in predict_is_ready caused by non-string message Resolved an issue in where a object was being checked with the operator, causing a . Converted to a string before performing the check to ensure compatibility. Added safeguards to handle non-string message types gracefully. --- annolid/gui/app.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/annolid/gui/app.py b/annolid/gui/app.py index 0ddb15d..6ade41f 100644 --- a/annolid/gui/app.py +++ b/annolid/gui/app.py @@ -1162,22 +1162,26 @@ def predict_is_ready(self, messege): "background-color: green; color: white;") self.stepSizeWidget.predict_button.setEnabled(True) self.stop_prediction_flag = False - if messege is not None and "last frame" in messege: - QtWidgets.QMessageBox.information( - self, "Stop early", - messege - ) - else: - if self.video_loader is not None: - num_json_files = count_json_files(self.video_results_folder) - logger.info( - f"Number of predicted frames: {num_json_files} in total {self.num_frames}") - if num_json_files >= self.num_frames: - # convert json labels to csv file - self.convert_json_to_tracked_csv() - QtWidgets.QMessageBox.information( - self, "Prediction Ready", - "Predictions for the video frames have been generated!") + try: + if messege is not None and "last frame" in str(messege): + QtWidgets.QMessageBox.information( + self, "Stop early", + messege + ) + else: + if self.video_loader is not None: + num_json_files = count_json_files( + self.video_results_folder) + logger.info( + f"Number of predicted frames: {num_json_files} in total {self.num_frames}") + if num_json_files >= self.num_frames: + # convert json labels to csv file + self.convert_json_to_tracked_csv() + QtWidgets.QMessageBox.information( + self, "Prediction Ready", + "Predictions for the video frames have been generated!") + except RuntimeError as e: + print(f"RuntimeError occurred: {e}") def loadFlags(self, flags): for key, flag in flags.items():