Files
church-translate/app/_probe-progress.mjs
T

35 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

/* Everything below is already on disk. Whatever this prints is what the app
calls "Downloading". */
import { pipeline, env } from '@huggingface/transformers';
import os from 'os'; import path from 'path';
env.allowLocalModels = false;
env.cacheDir = path.join(os.homedir(), 'Library/Application Support/Church Translate Models');
const seen = [];
const t0 = Date.now();
await pipeline('translation', 'Xenova/nllb-200-distilled-600M', {
dtype: 'fp32',
progress_callback: (p) => seen.push({ ms: Date.now() - t0, ...p })
});
const byStatus = {};
for (const e of seen) byStatus[e.status] = (byStatus[e.status] || 0) + 1;
console.log('event counts by status:', byStatus);
console.log('total events:', seen.length, 'over', ((Date.now()-t0)/1000).toFixed(1) + 's\n');
console.log('per file — did any bytes actually move?');
const files = {};
for (const e of seen) {
if (!e.file) continue;
const f = files[e.file] || (files[e.file] = { statuses: new Set(), maxTotal: 0, progressEvents: 0 });
f.statuses.add(e.status);
if (e.total) f.maxTotal = Math.max(f.maxTotal, e.total);
if (e.status === 'progress') f.progressEvents++;
}
for (const [name, f] of Object.entries(files)) {
console.log(' ' + name.padEnd(38) +
(f.maxTotal ? (f.maxTotal / 1048576).toFixed(1) + ' MB' : ' — ').padStart(10) +
' progress-events=' + String(f.progressEvents).padEnd(5) +
' [' + Array.from(f.statuses).join(', ') + ']');
}