add: more logging for filter's workers

This commit is contained in:
alikia2x (寒寒) 2025-02-22 21:43:09 +08:00
parent bdbd2ac748
commit f70401846a
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6
3 changed files with 5 additions and 3 deletions

View File

@ -77,7 +77,7 @@ export async function getNullVideoTagsList(client: Client) {
);
}
export async function getUnlabeledVideos(client: Client) {
export async function getUnlabelledVideos(client: Client) {
const queryResult = await client.queryObject<{ aid: number }>(
`SELECT a.aid FROM all_data a LEFT JOIN labelling_result l ON a.aid = l.aid WHERE l.aid IS NULL`,
);

View File

@ -28,6 +28,7 @@ export async function initializeModels() {
sessionClassifier = classifierSession;
sessionEmbedding = embeddingSession;
logger.log("Filter models initialized", "ml");
} catch (error) {
const e = new WorkerError(error as Error, "ml", "fn:initializeModels");
throw e;

View File

@ -1,6 +1,6 @@
import { Job } from "bullmq";
import { db } from "lib/db/init.ts";
import { getUnlabeledVideos, getVideoInfoFromAllData, insertVideoLabel} from "lib/db/allData.ts";
import { getUnlabelledVideos, getVideoInfoFromAllData, insertVideoLabel} from "lib/db/allData.ts";
import { classifyVideo, initializeModels } from "lib/ml/filter_inference.ts";
import { ClassifyVideoQueue } from "lib/mq/index.ts";
import logger from "lib/log/logger.ts";
@ -35,7 +35,8 @@ export const classifyVideoWorker = async (job: Job) => {
export const classifyVideosWorker = async () => {
await initializeModels();
const client = await db.connect();
const videos = await getUnlabeledVideos(client);
const videos = await getUnlabelledVideos(client);
logger.log(`Found ${videos.length} unlabelled videos`)
client.release();
let i = 0;
for (const aid of videos) {