Pin Applio 3.6.5 and verified basis assets, migrate private voice provenance, and coordinate conversion/live/training with Deck GPU leases. Prepare an inactive voice profile and a restricted studio container. Move CUDA and Torch caches out of the small temporary filesystem to prevent OmniVoice reference failures. Package app updates from the explicit allowlist in one Docker layer.
51 lines
3.3 KiB
Python
51 lines
3.3 KiB
Python
import json,socket,tempfile,time,unittest
|
|
from pathlib import Path
|
|
from types import SimpleNamespace
|
|
from unittest.mock import patch
|
|
from applio import Applio,applio_model
|
|
from execution_setup import assess
|
|
class Tests(unittest.TestCase):
|
|
def setUp(self):
|
|
self.tmp=tempfile.TemporaryDirectory();self.active=[];self.leases=0
|
|
self.runtime=SimpleNamespace(status=lambda:{'installed':False},paths=lambda:(Path('/missing'),Path('/missing')))
|
|
self.scheduler=SimpleNamespace(gpu_mode='voice',image_reservation=self.reserve)
|
|
self.profile=dict(id='test',name='RVC',kind='voice',runnable=True,model={'kind':'voice','file':'voice.pth','runtime_metadata':{'architecture':'rvc'}})
|
|
self.profiles=SimpleNamespace(status=lambda:{'profiles':[self.profile]})
|
|
self.a=Applio(Path(self.tmp.name),self.runtime,self.scheduler,self.profiles,lambda:self.active)
|
|
def tearDown(self):self.a.stop();self.tmp.cleanup()
|
|
def reserve(self,*args,**kwargs):
|
|
self.leases+=1
|
|
def release():self.leases-=1
|
|
return release
|
|
def connect(self):
|
|
c=socket.socket(socket.AF_UNIX);c.connect(str(self.a.socket));c.sendall(b'{"action":"reserve"}\n');return c,json.loads(c.makefile('rb').readline())
|
|
def test_requires_active_profile_and_voice_mode(self):
|
|
c,d=self.connect();self.assertIn('error',d);c.close();self.assertEqual(self.leases,0)
|
|
self.active=['test'];self.scheduler.gpu_mode='music';c,d=self.connect();self.assertIn('error',d);c.close();self.assertEqual(self.leases,0)
|
|
def test_disconnect_releases_gpu_and_competing_request_does_not_clear_active(self):
|
|
self.active=['test']
|
|
with patch('image_test.probe',return_value=[dict(name='RTX 3060',uuid='GPU-test')]):
|
|
c,d=self.connect();self.assertEqual(d['gpu'],'GPU-test');self.assertEqual(self.leases,1)
|
|
other,result=self.connect();self.assertIn('error',result);other.close();time.sleep(.05);self.assertTrue(self.a.active)
|
|
with self.assertRaises(ValueError):self.a.configure({'device':'5080'})
|
|
c.close()
|
|
for _ in range(100):
|
|
if not self.a.active:break
|
|
time.sleep(.01)
|
|
self.assertEqual(self.leases,0);self.assertFalse(self.a.active)
|
|
def test_real_profile_is_runnable_only_after_runtime_ready(self):
|
|
from catalog import Catalog
|
|
from profiles import Profiles
|
|
root=Path(self.tmp.name);catalog=Catalog(root/'models');folder=catalog.root/('a'*64);folder.mkdir(parents=True);(folder/'model.pth').write_bytes(b'test');(folder/'entry.json').write_text(json.dumps(dict(repo='local/mikes-applio',revision='b'*64,file='voice.pth',kind='voice',size=4,sha256='b'*64,runtime_metadata={'architecture':'rvc'})))
|
|
profiles=Profiles(root/'profiles.json',catalog);row=profiles.save(dict(id=None,revision=0,name='Applio RVC',api_id='applio-rvc',kind='voice',model_id='a'*64,parameters={}))
|
|
profiles.applio_blockers=lambda p:['Laufzeit fehlt']
|
|
self.assertFalse(profiles.status()['profiles'][0]['runnable'])
|
|
profiles.applio_blockers=lambda p:[]
|
|
self.assertTrue(profiles.status()['profiles'][0]['runnable'])
|
|
def test_rvc_recognition_does_not_guess_every_pth(self):
|
|
self.assertTrue(applio_model(self.profile['model']))
|
|
self.assertFalse(applio_model(dict(kind='voice',file='voice.pth')))
|
|
result=assess(self.profile['model'],{'applio':True})
|
|
self.assertEqual(result['setup_steps'][1]['state'],'complete');self.assertEqual(result['components'],[])
|
|
if __name__=='__main__':unittest.main()
|