Files
aigc-home/docs/hel-892/animate-mask-document-evidence/browser-mask.py.txt
T

53 lines
8.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from pathlib import Path
R=Path.cwd();old=R/'e2e/animate-document.mjs';s=old.read_text()
s=s.replace("const names=['Wan2.2_Animate_SAM3", "const names=['Wan2.2_Animate_人物遮罩替换(官流整理)','Wan2.2_Animate_SAM3")
s=s.replace('.local-evidence/animate-document/browser','.local-evidence/animate-mask-document/browser').replace('animate-document-evidence','animate-mask-document-evidence').replace("group='aggregate'","group='aggregate'").replace('new_animate','new_animate_mask').replace('old_one_hundred_forty_two','old_one_hundred_forty_three')
s=s.replace('details.length===143','details.length===144').replace('===9749','===9985').replace("'143图9749保存条目'","'144图9985保存条目'").replace('===275','===282').replace("'143图275源注释'","'144图282源注释'")
a=s.index(' check(b.counts.saved_fields===');z=s.index(' const notesBox=',a)
s=s[:a]+''' check(b.fields.length===236&&b.counts.root_saved_fields===185&&b.counts.internal_saved_fields===51,`${width}236保存/root185/internal51`);
check(b.node_bindings.filter(x=>x.implementation_verified).length===55&&b.node_bindings.filter(x=>x.source_id.startsWith('unresolved-')).map(x=>x.node_id).sort().join(',')==='232:62,375:362,409:428'&&b.node_bindings.filter(x=>x.source_id==='unknown-no-version').length===66,`${width}55准确/三WanAnimate提交键缺口/66未知`);
check(b.fields.every(f=>f.named_state==='missing'&&!('named_pointer'in f)&&!('named_value'in f)),`${width}所有scope零具名不造双指针`);
const source=JSON.parse(fs.readFileSync('docs/hel-892/animate-mask-document-evidence/source-check.json'));
const original=JSON.parse(fs.readFileSync('example_ComfyUI_workflows/6-动作迁移/Wan2.2_Animate_人物遮罩替换(官流整理).json'));
const expected=JSON.parse(fs.readFileSync('docs/hel-892/animate-mask-document-evidence/expected-edges.json'));
const node=n=>JSON.parse(b.flow.find(x=>x.startsWith(n+' 原节点完整保存 ')).split(' 原节点完整保存 ')[1]);
for(const [scope,edges]of Object.entries(expected)){
const lines=b.flow.filter(x=>x.startsWith(scope+' 物理/边界记录 '));assert.deepEqual(lines.map(x=>JSON.parse(x.split(' 物理/边界记录 ')[1])),edges);check(true,`${width} ${scope}全部端点/记录按原值`);
}
check(b.counts.source_nodes===134&&b.counts.physical_edges===198&&b.counts.proxy_widgets===30,`${width}134节点/198分scope记录/30proxy`);
check(b.boundaries.map(x=>x.proxy_mappings.length).join(',')==='9,10,11',`${width}三宿主proxy9/10/11独立`);
for(const h of b.boundaries){
const host=original.nodes.find(n=>String(n.id)===h.host_node_id);const def=original.definitions.subgraphs.find(d=>d.id===h.definition_id);
assert.deepEqual(h.host,host);assert.deepEqual(h.widgets,[]);assert.deepEqual(host.widgets_values,[]);assert.deepEqual(h.proxy_mappings.map(x=>x.raw_pair),host.properties.proxyWidgets);
for(const m of h.proxy_mappings){const f=b.fields.find(f=>f.pointer===m.internal_saved_pointer);assert.ok(f);assert.deepEqual(m.internal_saved_value,f.value);check(!m.host_value_generated&&m.field===f.field&&m.definition_node_id===f.definition_node_id,`${width}宿主${h.host_node_id} proxy ${m.raw_pair.join('.')}实际定义槽/不补宿主值`);}
check(def.nodes.every(n=>n.mode===0&&n.properties.ver==='0.3.59'),`${width}宿主${h.host_node_id}不传播版本/定义全mode0`);
}
const scoped=JSON.parse(fs.readFileSync('docs/hel-892/animate-mask-document-evidence/scoped-edge-check.json'));
check(scoped.duplicate_boundary_declarations.some(x=>x.id===187&&x.count===2)&&scoped.node_port_inconsistencies.length===4&&scoped.boundary_port_inconsistencies.length===1&&!scoped.repaired,`${width}原重复187及四出口/一边界不一致保留`);
check(node('430').mode===4&&b.node_bindings.find(n=>n.node_id==='430').source_id==='unknown-no-version',`${width}430无身份mode4独立`);
check(node('229').outputs[0].links.join(',')==='438'&&node('229').outputs.slice(1).every(x=>x.links===null)&&node('107').inputs.find(x=>x.name==='coordinates_negative').link===null,`${width}仅正点438/负点和框裁图出口null`);
assert.deepEqual(node('229').widgets_values.slice(-2),['',null]);check(node('229').widgets_values[8]===false&&b.fields.every(f=>f.json_type!=='float'),`${width}normalize false/额外空串null/零保存float`);
check(b.fields.filter(f=>f.json_type==='dict').length===4&&b.zero_saved_nodes.find(n=>n.node_id==='417').state==='empty_dict',`${width}四完整历史/417完整空dict`);
check(node('100').widgets_values.slice(0,3).join(',')==='disable,disable,enable'&&node('101').widgets_values.slice(0,3).join(',')==='enable,enable,disable',`${width}两组DW手身脸各自开关`);
check(node('232:63').widgets_values[0]===82785393657702&&node('232:63').widgets_values[1]==='randomize'&&node('375:365').widgets_values[0]===387378783691204&&node('409:423').widgets_values[0]===387378783691204,`${width}三普通core采样seed/控制原值不求值`);
check(node('375:362').widgets_values[2]===0&&node('409:428').widgets_values[2]===77,`${width}两Extend length0/77缓存独立`);
check(typeof node('412').widgets_values[0]==='number'&&node('416').widgets_values[0]==='16.0'&&node('372').widgets_values[0]===81,`${width}源int16/历史str16.0/int81不混用`);
for(const id of ['287','288','289'])check(node(id).inputs.find(x=>x.name==='audio').link===null&&node(id).outputs[0].links===null,`${width}预览${id}无audio线/Filenames null`);
check(original.extra.frontendVersion==='1.32.1'&&b.sources.filter(e=>e.id==='frontend').every(e=>e.commit===b.sources.find(e=>e.id==='frontend').commit),`${width}准确前端1.32.1同树内置LG而非0.15.15`);
for(const e of b.sources.filter(e=>e.claim.includes('本图实际复核UTC'))){check(Number.isFinite(Date.parse(e.reverified_at))&&(!/^\\d{4}-/.test(e.acquisition_time||'')||Date.parse(e.reverified_at)>=Date.parse(e.acquisition_time)),`${width}来源实际复核日期${e.file}`);}
''' + s[z:]
a=s.index(" for(const [phrase,label]of [");z=s.index(" await dialog.getByText('版本、源图与连线依据'",a)
s=s[:a]+''' for(const [phrase,label]of [['本图独立root114','scope'],['准确主前端1.32.1','frontend'],['本图SAM2','sam2'],['229准确KJ','points'],['100/101 DW','dw'],['三个WanAnimateToVideo','core-gap'],['第一定义63普通core','first-sampler'],['两Extend365/423','extend'],['291准确VHS','video-info'],['287/288/289三个VHS','preview-save'],['原声明不一致完整清单','edge-conflicts']]){
const line=b.flow.filter(x=>x.includes(phrase)).sort((a,b)=>a.length-b.length)[0];assert.ok(line,phrase);await fixedCard.getByText(line,{exact:true}).first().evaluate(el=>el.scrollIntoView({block:'start'}));await page.screenshot({path:`${out}/${width}-${d.id}-${label}.png`});
}
''' + s[z:]
a=s.index(" if(['630.seed'");z=s.index(' await summary.click();',a)
s=s[:a]+''' if(['229.points_store','229.coordinates','229.neg_coordinates','229.position_9','229.position_10','107.keep_model_loaded','108.segmentor','158.image_gen_width','212.width','287.videopreview','288.videopreview','289.videopreview','291.videopreview','412.value','416.position_0','232:63.seed','232:62.width','375:362.length','409:428.length','375:365.control_after_generate','409:423.cfg'].includes(f.node_id+'.'+f.field)){await summary.evaluate(el=>el.scrollIntoView({block:'start'}));await page.screenshot({path:`${out}/${width}-${d.id}-${f.node_id.replaceAll(':','_')}-${f.field}.png`});}
''' + s[z:]
# Every cited source with a date is visibly tied to its actual source read, not a batch start.
s=s.replace("text.includes(e.sha256)&&text.includes(e.lines.join('~'))", "text.includes(e.sha256)&&text.includes(e.lines.join('~'))&&(!e.claim.includes('本图实际复核UTC')||text.includes(e.reverified_at))")
(R/'e2e/animate-mask-document.mjs').write_text(s)
for n in ['run-animate-document.py','animate-document-server.py']:
s=(R/'e2e'/n).read_text().replace('animate-document','animate-mask-document').replace('definitions"] == 143','definitions"] == 144')
(R/'e2e'/n.replace('animate-document','animate-mask-document')).write_text(s)