← back to Wallco Ai
scripts/drunk_animals_batch.js
58 lines
#!/usr/bin/env node
/**
* Fire a batch of N drunk-animal-in-forest, botanical-pop-Warhol designs
* through scripts/generate_designs.js. Each design uses a unique prompt
* from drunk_animal_prompts.buildN().
*
* Usage: node scripts/drunk_animals_batch.js [N] (default 20)
*
* Each design is pipelined separately so a single Replicate failure
* doesn't kill the whole batch. The generator writes to
* dw_unified.spoon_all_designs with kind='seamless_tile', category='drunk-animals'.
*/
const { spawnSync } = require('child_process');
const path = require('path');
const { buildN } = require('./drunk_animal_prompts');
const { checkPrompt } = require('./settlement-gate');
const N = parseInt(process.argv[2] || '20', 10);
const ROOT = path.join(__dirname, '..');
console.log(`\n=== Drunk-animal batch: firing ${N} designs ===\n`);
const prompts = buildN(N);
let ok = 0, fail = 0, skipped = 0;
for (let i = 0; i < prompts.length; i++) {
const p = prompts[i];
// Settlement gate — per-variant filter. Skip any prompt that BLOCKs so the
// batch keeps moving instead of dying at the first violation. NEEDS_REVIEW
// also skips (we don't want is_published=true from auto-batch).
const gate = checkPrompt(p);
if (gate.verdict !== 'OK') {
console.log(`\n--- [${i+1}/${N}] SKIP (settlement: ${gate.verdict}) — ${gate.reason || ''}`);
skipped++;
continue;
}
console.log(`\n--- [${i+1}/${N}] ${p.slice(0, 90)}…`);
const r = spawnSync('node', [
path.join(ROOT, 'scripts', 'generate_designs.js'),
'--n', '1',
'--kind', 'seamless_tile',
'--category', 'drunk-animals',
'--prompts', p,
], { stdio: 'inherit', cwd: ROOT });
if (r.status === 0) ok++; else fail++;
}
console.log(`\n=== Batch done: ${ok} ok, ${fail} failed, ${skipped} settlement-skipped ===`);
// Refresh designs.json from PG and push live server to reload its in-memory
// grid so the new batch shows on wallco.ai immediately.
spawnSync('python3', [path.join(ROOT, 'scripts', 'refresh_designs_snapshot.py')],
{ stdio: 'inherit', cwd: ROOT, timeout: 120_000 });
spawnSync('curl', ['-sf', '-m', '5', '-X', 'POST', 'http://127.0.0.1:9878/admin/reload-designs'],
{ stdio: 'inherit', cwd: ROOT, timeout: 10_000 });
process.exit(fail === 0 ? 0 : 1);