29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
"""Fetch only the pinned public codec into the isolated Athena experiment."""
|
|
import hashlib, json, os, shutil, urllib.request
|
|
from pathlib import Path
|
|
|
|
root = Path('/opt/athena-deck-dev/runtime/state/experiments/tts-codec-q4-20261022')
|
|
root.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
os.chown(root, 65534, 65534)
|
|
name = 'qwen-tokenizer-12hz-Q4_K_M.gguf'
|
|
revision = 'b7ee2e8c7459c3bea99da23e3d178125a7d1713c'
|
|
expected = 'cf3788b4d50aaa665fb6e57c170396aae03a3555fea52d2b5d0cda902d658039'
|
|
url = f'https://huggingface.co/Serveurperso/Qwen3-TTS-GGUF/resolve/{revision}/{name}'
|
|
path = root/name
|
|
if not path.exists():
|
|
part = path.with_suffix('.part')
|
|
with urllib.request.urlopen(url, timeout=120) as response, part.open('wb') as output:
|
|
shutil.copyfileobj(response, output, 1024*1024)
|
|
part.replace(path)
|
|
assert path.stat().st_size == 254974752
|
|
digest = hashlib.file_digest(path.open('rb'), 'sha256').hexdigest()
|
|
assert digest == expected, 'Public codec checksum mismatch'
|
|
path.chmod(0o600)
|
|
os.chown(path, 65534, 65534)
|
|
worker = root/'worker.py'
|
|
shutil.copyfile(Path(__file__).with_name('worker.py'), worker)
|
|
worker.chmod(0o600)
|
|
os.chown(worker, 65534, 65534)
|
|
print(json.dumps(dict(codec=name, size=path.stat().st_size, sha256=digest,
|
|
production_model_unchanged=True)), flush=True)
|