Skip to content

Split any YouTube song into stems

TypeScript

test: run production key detection in smoke self-test

David Naviac8545a59000a
diff --git a/src/main/smoke.ts b/src/main/smoke.ts
index 3c3577f..4e72bf0 100644
--- a/src/main/smoke.ts
+++ b/src/main/smoke.ts
@@ -9,7 +9,6 @@ import {
getStatus,
venvPython,
separateScript,
- keyScript,
roformerScript,
modelsDir,
bundledFfmpeg,
@@ -18,6 +17,7 @@ import {
detectNvidiaGpu,
detectAmdGpu
} from './env'
+import { runKeyScript } from './keydetect'
/* self-test mode, driven by STEMKIT_SMOKE=1 (used by the windows-smoke CI
job and manually on linux): runs the real bootstrap then separates a
@@ -83,43 +83,6 @@ function runScript(cmd: string, args: string[]): Promise<ScriptResult> {
})
}
-/* key.py reports {"type":"key"} rather than stems, so runScript's stem check
- would reject every good run; this only needs the key line and exit 0 */
-function runKeyDetection(mix: string): Promise<{ ok: boolean; error?: string }> {
- return new Promise((resolve) => {
- log(`run: ${venvPython()} ${keyScript()} --input ${mix}`)
- const child = spawn(venvPython(), [keyScript(), '--input', mix], { env: { ...process.env } })
- let error: string | undefined
- let keyFound = false
- createInterface({ input: child.stdout! }).on('line', (line) => {
- let parsed: Record<string, unknown>
- try {
- parsed = JSON.parse(line)
- } catch {
- return
- }
- if (parsed.type === 'key') keyFound = true
- else if (parsed.type === 'error') error = String(parsed.message)
- })
- let stderr = ''
- child.stderr?.on('data', (c: Buffer) => {
- stderr += c.toString()
- })
- child.on('close', (code) => {
- if (code === 0 && keyFound && !error) resolve({ ok: true })
- else
- resolve({
- ok: false,
- error:
- error ??
- (stderr ? stderr.slice(-500) : undefined) ??
- `exit code ${code}, no key reported`
- })
- })
- child.on('error', (e) => resolve({ ok: false, error: String(e) }))
- })
-}
-
function generateMix(dest: string): Promise<void> {
const ffmpeg = bundledFfmpeg()
if (!ffmpeg) throw new Error('bundled ffmpeg not found')
@@ -230,12 +193,13 @@ export async function runSmoke(): Promise<boolean> {
}
}
- const key = await runKeyDetection(mix)
- if (!key.ok) {
- log(`FAIL: key detection: ${key.error}`)
+ log(`run: key detection on ${mix}`)
+ const key = await runKeyScript([mix])
+ if (key.detected === null) {
+ log('FAIL: key detection')
return false
}
- log('key detection ok')
+ log(`key detection ok: ${key.detected}`)
// roformer engine on CPU: validates the vendored model code, extra pip
// deps and its own checkpoint downloader on this platform