From 73b96e869d4cb7406f467c67fac8e6c01e5f17d0 Mon Sep 17 00:00:00 2001 From: alikia2x Date: Sat, 22 Feb 2025 22:29:30 +0800 Subject: [PATCH] fix: move filter model init to an earlier stage --- lib/mq/exec/classifyVideo.ts | 4 +--- src/filterWorker.ts | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/mq/exec/classifyVideo.ts b/lib/mq/exec/classifyVideo.ts index aa09d8c..d2a9c70 100644 --- a/lib/mq/exec/classifyVideo.ts +++ b/lib/mq/exec/classifyVideo.ts @@ -1,7 +1,7 @@ import { Job } from "bullmq"; import { db } from "lib/db/init.ts"; import { getUnlabelledVideos, getVideoInfoFromAllData, insertVideoLabel} from "lib/db/allData.ts"; -import { classifyVideo, initializeModels } from "lib/ml/filter_inference.ts"; +import { classifyVideo } from "lib/ml/filter_inference.ts"; import { ClassifyVideoQueue } from "lib/mq/index.ts"; import logger from "lib/log/logger.ts"; import { lockManager } from "lib/mq/lockManager.ts"; @@ -41,8 +41,6 @@ export const classifyVideosWorker = async () => { lockManager.acquireLock("classifyVideos"); - await initializeModels(); - const client = await db.connect(); const videos = await getUnlabelledVideos(client); logger.log(`Found ${videos.length} unlabelled videos`) diff --git a/src/filterWorker.ts b/src/filterWorker.ts index 57487f6..9746477 100644 --- a/src/filterWorker.ts +++ b/src/filterWorker.ts @@ -4,6 +4,7 @@ import logger from "lib/log/logger.ts"; import { classifyVideosWorker, classifyVideoWorker } from "lib/mq/exec/classifyVideo.ts"; import { WorkerError } from "lib/mq/schema.ts"; import { lockManager } from "lib/mq/lockManager.ts"; +import { initializeModels } from "lib/ml/filter_inference.ts"; Deno.addSignalListener("SIGINT", async () => { logger.log("SIGINT Received: Shutting down workers...", "mq"); @@ -17,6 +18,9 @@ Deno.addSignalListener("SIGTERM", async () => { Deno.exit(); }); + +await initializeModels(); + const filterWorker = new Worker( "classifyVideo", async (job: Job) => {