"""Pinned native ACE-Step runtime, isolated from every other audio worker.""" import json,os,shutil,sys,time from pathlib import Path from ltx_original_runtime import LTXOriginalRuntime REVISION='dce621408bee8c31b4fcf4811682eb9359e1bc94' VERSION='1.5 · '+REVISION[:8] class AceStepRuntime(LTXOriginalRuntime): name='ACE-Step' def __init__(self,root):super().__init__(root,None) def paths(self): try: ident=json.loads((self.root/'active.json').read_text())['id'] if len(ident)==32 and all(c in '0123456789abcdef' for c in ident): base=self.root/ident if (base/'ready').read_text().strip()==REVISION:return base/'python/bin/python',base/'source' except (OSError,ValueError,KeyError):pass return self.root/'missing-python',self.root/'missing-source' def status(self): python,source=self.paths() return dict(installed=python.is_file() and source.is_dir(),version=VERSION,job=dict(self.job) if self.job else None,required_disk_gib=30,shared_cuda=False,worker_available=True,origin='ace-step/ACE-Step-1.5 · offizieller Quellstand des bisherigen Routers',message='Eigene Python/PyTorch-Umgebung. Kein Modell wird während der Installation geladen.') def _run(self): base=self.root/self.job['id'];state='failed';phase='ACE-Step-Einrichtung fehlgeschlagen.' try: base.mkdir(mode=0o700);tmp=base/'tmp';tmp.mkdir() env=dict(os.environ,TMPDIR=str(tmp),PIP_NO_INPUT='1',PIP_DISABLE_PIP_VERSION_CHECK='1',GIT_TERMINAL_PROMPT='0',OMP_NUM_THREADS='2') self._phase('Eigene ACE-Step-Python-Umgebung erstellen');self._command([sys.executable,'-m','venv',base/'python'],env) python=base/'python/bin/python';source=base/'source' self._command([python,'-c','import sys;assert (3,11)<=sys.version_info[:2]<(3,13)'],env) self._phase('Offizielle ACE-Step-Quelle herunterladen') self._command(['git','init',source],env);self._command(['git','-C',source,'fetch','--depth','1','https://github.com/ace-step/ACE-Step-1.5.git',REVISION],env);self._command(['git','-C',source,'checkout','--detach','FETCH_HEAD'],env) self._phase('Eigene CUDA-Pakete installieren · andere Laufzeiten bleiben unverändert') self._command([python,'-m','pip','install','--no-cache-dir','torch==2.10.0','torchvision==0.25.0','torchaudio==2.10.0','--index-url','https://download.pytorch.org/whl/cu128'],env) self._phase('Geprüfte ACE-Step-Abhängigkeiten installieren') self._command([python,'-m','pip','install','--no-cache-dir','-r',Path(__file__).parent/'deploy/acestep-requirements.lock'],env) self._command([python,'-m','pip','install','--no-deps',source],env) self._phase('Handler und CPU-Import prüfen · kein Modellstart') self._command([python,'-c','from acestep.handler import AceStepHandler;from acestep.llm_inference import LLMHandler;from acestep.inference import generate_music;import torch;assert torch.version.cuda'],dict(env,CUDA_VISIBLE_DEVICES='')) if self.cancel.is_set():raise InterruptedError() (base/'ready').write_text(REVISION);marker=self.root/'active.tmp';marker.write_text(json.dumps(dict(id=base.name)));marker.replace(self.root/'active.json') state='complete';phase='ACE-Step installiert · Musikprofil unter Musikgenerierung einrichten' except InterruptedError:phase='ACE-Step-Einrichtung abgebrochen.' except Exception as exc:phase=str(exc) finally: with self.lock:self.process=None;self.job.update(state=state,phase=phase,finished_at=time.time());self._save()