Files
aigc-home/docs/hel-892/wanplus-document-evidence/extend-wanplus.py.txt
T
2026-11-01 19:07:30 +08:00

58 lines
5.1 KiB
Plaintext

from pathlib import Path
import json,hashlib,datetime,subprocess,concurrent.futures
R=Path.cwd();REF=R/'docs/hel-892/wanplus-reference';now=datetime.datetime.now(datetime.timezone.utc).isoformat()
s=(R/'.local-evidence/setup-anima.py').read_text();exec('def fetch(spec):'+s.split('def fetch(spec):')[1].split('with concurrent.futures')[0].replace('anima-','wanplus-'))
rows=json.loads((REF/'sources.json').read_bytes())['sources']
specs=[('cleanup-58de13a6','LAOGOU-666/Comfyui-Memory_Cleanup','58de13a6090e04408e343501ff8902c034d9f518',['__init__.py','LICENSE','requirements.txt','pyproject.toml']),('canonical-761b1d19','kijai/ComfyUI-WanVideoWrapper','761b1d191e50d589465e31dc0d40ff7c59b1b7b0',['__init__.py','nodes.py','utils.py','LICENSE','requirements.txt','pyproject.toml']),('wascanonical-afeee09b','ltdrdata/was-node-suite-comfyui','afeee09ba44e713ec52a413ac6b105fd06b2d356',['WAS_Node_Suite.py','__init__.py','LICENSE','requirements.txt','pyproject.toml'])]
failures=[]
with concurrent.futures.ThreadPoolExecutor(max_workers=3)as pool:
futs={pool.submit(fetch,s):s for s in specs}
for fut in concurrent.futures.as_completed(futs):
try:rows+=fut.result()
except Exception as e:failures.append(dict(spec=futs[fut],error=str(e)));print('FAILED canonical',futs[fut][0],str(e),flush=True)
(REF/'canonical-fetch-failures.json').write_text(json.dumps(failures,ensure_ascii=False,indent=2)+'\n')
(REF/'sources.json').write_text(json.dumps(dict(sources=rows),ensure_ascii=False,indent=2)+'\n')
selections={
'wanvideowrapper-c3bb8e98':['nodes.py','nodes_sampler.py','nodes_model_loading.py','utils.py'],
'wananimateplus-8868eedf':['nodes.py','utils.py'],
'wananimateplus-974d76c2':['nodes.py'],
'wananimateplus-1607e3ce':['nodes.py','nodes_sampler.py'],
'wananimateplus-493abd3b':['nodes_model_loading.py'],
'wanvideowrapper-967d1532':['uni3c/nodes.py','utils.py'],
'wanvideowrapper-a19d6bf1':['nodes.py','uni3c/nodes.py','utils.py'],
'kjnodes-f7eb33ab':['nodes/image_nodes.py'], 'kjnodes-468fcc86':['nodes/image_nodes.py'], 'kjnodes-068d4fee':['nodes/image_nodes.py'],
'kjnodes-a34c5884':['nodes/image_nodes.py'], 'kjnodes-e27a505b':['nodes/audio_nodes.py'], 'kjnodes-37659859':['nodes/nodes.py'],
'core0240':['comfy_extras/nodes_sam3.py','comfy/sd.py','comfy/model_detection.py','comfy_api/latest/_io.py','comfy_api/latest/_io_public.py'],
'core0270':['comfy_extras/nodes_sam3.py','comfy_api/latest/_io.py','comfy_api/latest/_io_public.py'],
'core0201':['comfy_extras/nodes_mask.py','comfy_extras/nodes_images.py','comfy_api/latest/_io.py'],
'core0280':['comfy_extras/nodes_primitive.py','comfy_api/latest/_io.py'],
'comfyliterals-bdddb08c':['nodes.py','README.md'],
'rgthree-comfy-42e73c3c':['py/seed.py','py/constants.py','py/utils.py','web/comfyui/seed.js','web/comfyui/base_node.js'],
}
for key in ['videohelpersuite-dabda542','videohelpersuite-4ee72c06','videohelpersuite-0edce8ef']:
selections[key]=['videohelpersuite/nodes.py','videohelpersuite/utils.py','video_formats/h264-mp4.json','web/js/VHS.core.js']
selections['videohelpersuite-8e4d7947']=['videohelpersuite/nodes.py','videohelpersuite/load_video_nodes.py','videohelpersuite/utils.py','web/js/VHS.core.js']
selections['videohelpersuite-537f3a02']=['videohelpersuite/nodes.py','videohelpersuite/utils.py']
def extend(item):
key,files=item;entry=next(e for e in rows if e['id']==key);commit=entry['commit'];tree=json.loads((REF/(key+'-tree.json')).read_bytes())['tree'];cache=R/('.local-evidence/wanplus-'+key+'-git');result=[]
for f in files:
ent=next((x for x in tree if x['path']==f),None)
if not ent:print('MISSING selected',key,f,flush=True);continue
raw=subprocess.check_output(['git','-C',str(cache),'show',commit+':'+f],timeout=90);assert len(raw)<3000000
name=key+'__'+f.replace('/','__');(REF/name).write_bytes(raw);result.append(dict(entry,file=f,local_file=name,url=f'https://raw.githubusercontent.com/{entry["repo"]}/{commit}/{f}',sha256=hashlib.sha256(raw).hexdigest(),git_blob_sha1=ent['sha'],acquisition_time=now,reverified_at=now,prior_exact_bytes_record=False))
print('SELECT',key,len(result),flush=True);return result
with concurrent.futures.ThreadPoolExecutor(max_workers=4)as pool:
for result in pool.map(extend,selections.items()):rows+=result
old=[]
for p in (R/'docs/hel-892').glob('*reference/sources.json'):
if p.parent==REF:continue
try:old+=json.loads(p.read_bytes())['sources']
except (KeyError,TypeError):continue
for e in rows:
if e['id'] in ['cleanup-58de13a6','wascanonical-afeee09b']:e['acquisition_time']='未知:此前作者失败运行已取得,未记录准确首次时间;本批复核另列'
before=next((x for x in old if x.get('commit')==e['commit']and x.get('file')==e['file']and x.get('sha256')==e['sha256']),None)
if before:e['acquisition_time']=before.get('acquisition_time','未知:旧记录未载首次获取时间');e['prior_exact_bytes_record']=True
e['license_file']=next((x['local_file']for x in rows if x['id']==e['id'] and x['file'].lower()in ['license','license.txt','license.md']),'未知:准确所选路径无许可')
(REF/'sources.json').write_text(json.dumps(dict(sources=rows),ensure_ascii=False,indent=2)+'\n')
print('FINAL ROWS',len(rows),flush=True)