Files

22 lines
1.6 KiB
Python

import os,sys,subprocess,json,time,hashlib
from pathlib import Path
r=Path(os.environ.get('VEVO2_TEST_ROOT','/data'));python=r/'python/bin/python'
os.environ.update(CUDA_VISIBLE_DEVICES='',HF_HOME=str(r/'hf-cache'),HF_HUB_DISABLE_IMPLICIT_TOKEN='1',HF_HUB_OFFLINE='1',TRANSFORMERS_OFFLINE='1',OMP_NUM_THREADS='2')
def status(state,phase):(r/'status.json').write_text(json.dumps(dict(state=state,phase=phase,time=time.time())))
def run(args):
with (r/'prepare.log').open('ab') as f:subprocess.run([str(a) for a in args],stdout=f,stderr=f,check=True)
try:
status('running','Ergänzende Importe im offiziellen Vevo2-Modul bereitstellen')
run([python,'-m','pip','install','--no-cache-dir','pyworld==0.3.5','torchmetrics==1.8.2','ruamel.yaml==0.18.16'])
s=r/'checkout'/Path((r/'source-path.txt').read_text()).name
run([python,'-c',"import sys,torch;sys.path.insert(0,sys.argv[1]);from models.svc.vevo2.vevo2_utils import Vevo2InferencePipeline;assert not torch.cuda.is_available();print('CPU_IMPORT_OK')",s])
with (r/'requirements.lock').open('wb') as f:subprocess.run([str(python),'-m','pip','freeze'],stdout=f,check=True)
assets=[]
for folder in (r/'model',r/'whisper-cache'):
for p in folder.rglob('*'):
if p.is_file() and '.cache' not in p.parts:
with p.open('rb') as f:h=hashlib.file_digest(f,'sha256').hexdigest()
assets.append(dict(path=str(p.relative_to(r)),size=p.stat().st_size,sha256=h))
(r/'assets.json').write_text(json.dumps(assets,indent=2));status('ready','Gewichte und CPU-Import geprüft; wartet auf freien GPU-Test')
except Exception as e:status('failed',type(e).__name__+': '+str(e)[:300]);raise