luojunhui 2 hónapja
szülő
commit
bdb18db52b
1 módosított fájl, 46 hozzáadás és 46 törlés
  1. 46 46
      coldStartTasks/ai_pipeline/extract_video_best_frame.py

+ 46 - 46
coldStartTasks/ai_pipeline/extract_video_best_frame.py

@@ -305,53 +305,19 @@ class ExtractVideoBestFrame:
 
 
                 case "ACTIVE":
                 case "ACTIVE":
                     # video process successfully
                     # video process successfully
-                    try:
-                        best_frame_time_ms = google_ai.fetch_info_from_google_ai(
-                            prompt=extract_best_frame_prompt(),
-                            video_file=google_file,
-                        )
-                        print(best_frame_time_ms)
-                        if best_frame_time_ms:
-                            self.set_extract_result(
-                                task_id=task["id"],
-                                file_state="ACTIVE",
-                                best_frame_time_ms=best_frame_time_ms.strip(),
-                            )
-                        else:
-                            update_task_queue_status(
-                                db_client=self.db_client,
-                                task_id=task["id"],
-                                task="extract",
-                                ori_status=const.PROCESSING_STATUS,
-                                new_status=const.FAIL_STATUS,
-                            )
-                        # delete local file and google file
-                        if os.path.exists(video_local_path):
-                            os.remove(video_local_path)
-
-                        google_ai.delete_video(file_name)
-                        log(
-                            task=const.TASK_NAME,
-                            function="extract_best_frame_with_gemini_ai",
-                            message="video process successfully",
-                            data={
-                                "task_id": task["id"],
-                                "file_name": file_name,
-                                "state": state,
-                                "best_frame_time_ms": best_frame_time_ms,
-                            },
-                        )
-                    except Exception as e:
-                        log(
-                            task=const.TASK_NAME,
-                            function="extract_best_frame_with_gemini_ai",
-                            message="task_failed_inside_cycle",
-                            data={
-                                "task_id": task["id"],
-                                "track_back": traceback.format_exc(),
-                                "error": str(e),
-                            },
+                    # try:
+                    best_frame_time_ms = google_ai.fetch_info_from_google_ai(
+                        prompt=extract_best_frame_prompt(),
+                        video_file=google_file,
+                    )
+                    print(best_frame_time_ms)
+                    if best_frame_time_ms:
+                        self.set_extract_result(
+                            task_id=task["id"],
+                            file_state="ACTIVE",
+                            best_frame_time_ms=best_frame_time_ms.strip(),
                         )
                         )
+                    else:
                         update_task_queue_status(
                         update_task_queue_status(
                             db_client=self.db_client,
                             db_client=self.db_client,
                             task_id=task["id"],
                             task_id=task["id"],
@@ -359,6 +325,40 @@ class ExtractVideoBestFrame:
                             ori_status=const.PROCESSING_STATUS,
                             ori_status=const.PROCESSING_STATUS,
                             new_status=const.FAIL_STATUS,
                             new_status=const.FAIL_STATUS,
                         )
                         )
+                    # delete local file and google file
+                    if os.path.exists(video_local_path):
+                        os.remove(video_local_path)
+
+                    google_ai.delete_video(file_name)
+                    log(
+                        task=const.TASK_NAME,
+                        function="extract_best_frame_with_gemini_ai",
+                        message="video process successfully",
+                        data={
+                            "task_id": task["id"],
+                            "file_name": file_name,
+                            "state": state,
+                            "best_frame_time_ms": best_frame_time_ms,
+                        },
+                    )
+                    # except Exception as e:
+                    #     log(
+                    #         task=const.TASK_NAME,
+                    #         function="extract_best_frame_with_gemini_ai",
+                    #         message="task_failed_inside_cycle",
+                    #         data={
+                    #             "task_id": task["id"],
+                    #             "track_back": traceback.format_exc(),
+                    #             "error": str(e),
+                    #         },
+                    #     )
+                    #     update_task_queue_status(
+                    #         db_client=self.db_client,
+                    #         task_id=task["id"],
+                    #         task="extract",
+                    #         ori_status=const.PROCESSING_STATUS,
+                    #         new_status=const.FAIL_STATUS,
+                    #     )
 
 
         except Exception as e:
         except Exception as e:
             log(
             log(