Skip to content

Commit 5709369

Browse files
fix[notask]: run classification e2e on mobile (#2663)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 309446e commit 5709369

4 files changed

Lines changed: 19 additions & 2 deletions

File tree

packages/sdk/commands/bundle/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const BUILTIN_PLUGINS: Record<string, { exportName: string }> = {
99
"onnx-ocr": { exportName: "ocrPlugin" },
1010
"sdcpp-generation": { exportName: "diffusionPlugin" },
1111
"ggml-vla": { exportName: "vlaPlugin" },
12+
"ggml-classification": { exportName: "classificationPlugin" },
1213
};
1314

1415
export const BUILTIN_SUFFIXES = Object.keys(BUILTIN_PLUGINS);

packages/sdk/e2e/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const config = getDefaultConfig(__dirname);
77
config.resolver = config.resolver || {};
88

99

10-
const extraAssetExts = ['ogg', 'wma', 'aac', 'm4a', 'wav', 'mp3', 'txt', 'jsonl'];
10+
const extraAssetExts = ['ogg', 'wma', 'aac', 'm4a', 'wav', 'mp3', 'txt', 'jsonl', 'gguf'];
1111
config.resolver.assetExts = Array.from(
1212
new Set([...(config.resolver.assetExts || []), ...extraAssetExts])
1313
);

packages/sdk/e2e/tests/mobile/consumer.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,22 @@ resources.define("ocr", {
128128
config: { langList: ["en"] },
129129
});
130130

131+
async function resolveClassificationWeightsPath() {
132+
// @ts-ignore - Metro turns the bundled GGUF file into an asset module.
133+
// This path is relative to dist/tests/mobile/consumer.js after tsc.
134+
const assetModule = require("../../../node_modules/@qvac/classification-ggml/weights/mobilenetv3_3class_v3_fp16.gguf");
135+
return await resolveBundledAssetUri(assetModule);
136+
}
137+
131138
// Classification ships bundled weights inside @qvac/classification-ggml,
132-
// so no registry constant / pre-download is required.
139+
// so no registry constant / pre-download is required. On mobile the weight
140+
// file must still be resolved as a Metro asset and passed explicitly because
141+
// the Bare worker bundle does not expose package data files at __dirname.
133142
resources.define("classification", {
134143
type: "classification",
144+
config: async () => ({
145+
modelPath: await resolveClassificationWeightsPath(),
146+
}),
135147
});
136148

137149
resources.define("sharded-embeddings", {

packages/sdk/e2e/tests/test-definitions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { kvCacheTests } from "./kv-cache-tests.js";
1616
import { errorTests } from "./error-tests.js";
1717
import { toolsTests } from "./tools-tests.js";
1818
import { ocrTests } from "./ocr-tests.js";
19+
import { classificationTests } from "./classification-tests.js";
1920
import { ttsTests } from "./tts-tests.js";
2021
import { configReloadTests } from "./config-reload-tests.js";
2122
import { loggingTests } from "./logging-tests.js";
@@ -252,6 +253,9 @@ export const tests = [
252253
// OCR tests
253254
...ocrTests,
254255

256+
// Classification tests
257+
...classificationTests,
258+
255259
// TTS tests
256260
...ttsTests,
257261

0 commit comments

Comments
 (0)