Add align/recheck/compare, plugins, and refresh Agent docs.
selftest / selftest (push) Canceled after 0s
selftest / selftest (push) Canceled after 0s
Wire deliver_report/listen_pack/retry hooks; gen --auto-retry and intro light check; make AGENTS_MIN the up-to-date agent entry with full command map. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+57
-4
@@ -340,6 +340,9 @@ def cmd_gen(args):
|
||||
dry_run=True)
|
||||
run.save_json("manifest.json", man_dry)
|
||||
catmod.append_entry(cfg, catmod.entry_from_gen(run.dir, man_dry))
|
||||
from ..plugins.hooks import bus
|
||||
bus.emit("after_gen", run_dir=run.dir, manifest=man_dry,
|
||||
cfg=cfg, args=args)
|
||||
log.info("dry-run 结束", seeds=seeds)
|
||||
log.close()
|
||||
return 0
|
||||
@@ -351,8 +354,21 @@ def cmd_gen(args):
|
||||
if not ok:
|
||||
raise ServerError("ComfyUI 不可达: %s" % info)
|
||||
|
||||
from ..plugins.hooks import bus
|
||||
from .extras import run_intro_check
|
||||
from ..plugins.retry_on_intro_fail.plugin import should_retry_intro_blob
|
||||
|
||||
cro = pmod.comfy_root(cfg=cfg)
|
||||
music = pmod.music_dir(cfg, cro)
|
||||
auto_retry = int(getattr(args, "auto_retry", 0) or 0)
|
||||
do_recheck = not bool(getattr(args, "skip_recheck", False))
|
||||
jobs = list(built)
|
||||
results = []
|
||||
for sd, wf, wf_path, sub in built:
|
||||
retries_left = auto_retry
|
||||
ji = 0
|
||||
while ji < len(jobs):
|
||||
sd, wf, wf_path, sub = jobs[ji]
|
||||
ji += 1
|
||||
pid = eng.submit_retry(wfmod.render(wf))
|
||||
log.info("已提交", seed=sd, prompt_id=pid)
|
||||
|
||||
@@ -364,7 +380,40 @@ def cmd_gen(args):
|
||||
results.append(dict(seed=sd, prompt_id=pid, files=outs,
|
||||
workflow=os.path.basename(wf_path)))
|
||||
|
||||
cro = pmod.comfy_root(cfg=cfg)
|
||||
if not do_recheck or not outs:
|
||||
continue
|
||||
audio = None
|
||||
for fn in outs:
|
||||
p = fn if os.path.isabs(fn) else os.path.join(
|
||||
music, os.path.basename(fn))
|
||||
if os.path.isfile(p):
|
||||
audio = p
|
||||
break
|
||||
if not audio:
|
||||
continue
|
||||
_code, blob = run_intro_check(
|
||||
cfg, audio, bpm=st["bpm"], intro_bars=ibars, lang=lang)
|
||||
run.save_json("intro_check.json", blob or {})
|
||||
log.info("开曲轻检", ok=(blob or {}).get("ok"))
|
||||
if should_retry_intro_blob(blob) and retries_left > 0:
|
||||
retries_left -= 1
|
||||
sd2 = seed_base + len(jobs)
|
||||
sub2 = "%s/%s-s%d-%s-%s" % (
|
||||
prefix, safe_title, len(jobs) + 1, style_tag, date_stamp)
|
||||
wf2 = wfmod.build_workflow(
|
||||
template, title=title, tags=tags, lyrics=lyrics, seed=sd2,
|
||||
bpm=st["bpm"], duration=st["duration"], keyscale=st["key"],
|
||||
sampler=cfg["sampler"], encode=cfg["encode"],
|
||||
model=cfg["model"], output_prefix=sub2, output_format=fmt,
|
||||
language=lang,
|
||||
timesignature=cfg["song"]["time_signature"])
|
||||
wf_path2 = run.path("wf_%s_s%d.json" % (safe_title, len(jobs) + 1))
|
||||
with open(wf_path2, "w", encoding="utf-8") as f:
|
||||
json.dump(wf2, f, ensure_ascii=False, indent=1)
|
||||
jobs.append((sd2, wf2, wf_path2, sub2))
|
||||
log.warn("开曲轻检 FAIL,追加 seed 重试", seed=sd2,
|
||||
left=retries_left)
|
||||
|
||||
manifest = dict(
|
||||
run_id=run.run_id, title=title, style=args.style,
|
||||
bpm=st["bpm"], key=st["key"], duration=st["duration"],
|
||||
@@ -375,16 +424,18 @@ def cmd_gen(args):
|
||||
intro_bars=ibars,
|
||||
sampler=cfg["sampler"], encode=cfg["encode"], model=cfg["model"],
|
||||
density=stats, results=results,
|
||||
output_dir=pmod.music_dir(cfg, cro),
|
||||
output_dir=music,
|
||||
created=datetime.datetime.now().isoformat(timespec="seconds"),
|
||||
)
|
||||
mpath = run.save_json("manifest.json", manifest)
|
||||
catmod.append_entry(cfg, catmod.entry_from_gen(run.dir, manifest))
|
||||
bus.emit("after_gen", run_dir=run.dir, manifest=manifest, cfg=cfg, args=args)
|
||||
log.info("全部完成", run=run.run_id, manifest=os.path.basename(mpath))
|
||||
|
||||
print("\n生成完成 run_id=%s" % run.run_id)
|
||||
print(" 时长 %ds BPM %d %s 种子 %s"
|
||||
% (st["duration"], st["bpm"], st["key"], seeds))
|
||||
% (st["duration"], st["bpm"], st["key"],
|
||||
[r["seed"] for r in results]))
|
||||
if inst:
|
||||
print(" [纯器乐] 无可唱歌词,密度闸门不适用")
|
||||
else:
|
||||
@@ -395,6 +446,8 @@ def cmd_gen(args):
|
||||
print(" seed=%s -> %s" % (r["seed"], ", ".join(r["files"] or ["无输出"])))
|
||||
print(" 产物目录: %s" % run.dir)
|
||||
print(" 音频输出: %s" % manifest["output_dir"])
|
||||
if os.path.isfile(run.path("report.md")):
|
||||
print(" 报告: %s" % run.path("report.md"))
|
||||
log.close()
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user