Load native Applio source in resident inference worker

This commit is contained in:
Mikei386 committed 2026-10-05 11:49:56 +02:00
1 parent 9069647508
commit 83cd31878c
2 files changed
+12 -1

No files matched your search

+3
View File
@@ -11,6 +11,9 @@ def main():
bind_parent() bind_parent()
if len(sys.argv)>1 and sys.argv[1]=="--exec": if len(sys.argv)>1 and sys.argv[1]=="--exec":
os.execv(sys.argv[2],sys.argv[2:]) os.execv(sys.argv[2],sys.argv[2:])
# A script launched from /app does not add its runtime working directory
# to Python's import path. RVC lives in the separately installed source tree.
sys.path.insert(0,os.environ.get('APPLIO_WORKDIR',os.getcwd()))
with contextlib.redirect_stdout(sys.stderr): with contextlib.redirect_stdout(sys.stderr):
from rvc.infer.infer import VoiceConverter from rvc.infer.infer import VoiceConverter
converter=VoiceConverter() converter=VoiceConverter()
+9 -1
View File
@@ -1,4 +1,4 @@
import json,socket,tempfile,time,unittest import json,os,socket,subprocess,sys,tempfile,time,unittest
from pathlib import Path from pathlib import Path
from types import SimpleNamespace from types import SimpleNamespace
from unittest.mock import patch from unittest.mock import patch
@@ -47,4 +47,12 @@ class Tests(unittest.TestCase):
self.assertFalse(applio_model(dict(kind='voice',file='voice.pth'))) self.assertFalse(applio_model(dict(kind='voice',file='voice.pth')))
result=assess(self.profile['model'],{'applio':True}) result=assess(self.profile['model'],{'applio':True})
self.assertEqual(result['setup_steps'][1]['state'],'complete');self.assertEqual(result['components'],[]) self.assertEqual(result['setup_steps'][1]['state'],'complete');self.assertEqual(result['components'],[])
class WorkerTests(unittest.TestCase):
def test_worker_imports_separate_runtime_and_serves_repeated_requests(self):
with tempfile.TemporaryDirectory() as directory:
root=Path(directory);module=root/'rvc/infer';module.mkdir(parents=True)
(root/'rvc/__init__.py').write_text('');(module/'__init__.py').write_text('')
(module/'infer.py').write_text('class VoiceConverter:\n def convert_audio(self,**kwargs): pass\n')
result=subprocess.run([sys.executable,str(Path(__file__).with_name('applio_worker.py'))],input='{}\n{}\n',text=True,capture_output=True,cwd='/',env=dict(os.environ,APPLIO_WORKDIR=str(root)),timeout=10,check=True)
self.assertEqual([json.loads(line) for line in result.stdout.splitlines()],[{'ready':True},{'ok':True},{'ok':True}])
if __name__=='__main__':unittest.main() if __name__=='__main__':unittest.main()