Add guided FLUX Klein component setup and tested image pipeline

This commit is contained in:
Mikei386
2026-09-28 23:16:01 +02:00
parent 43c8d6456c
commit 9fecb30a8f
8 changed files with 95 additions and 26 deletions
+13
View File
@@ -15,6 +15,19 @@ class ManagementTests(unittest.TestCase):
(target/'entry.json').write_text(json.dumps(self.entry));self.catalog=Catalog(self.root/'models');self.profiles=Profiles(self.root/'profiles.json',self.catalog)
def tearDown(self):self.tmp.cleanup()
def request(self):return dict(id=None,revision=0,name='image-test',kind='image',model_id=self.model_id,parameters=dict(width=1024,height=1024,steps=25,seed=-1,guidance=1))
def test_flux_recipe_requires_matching_components(self):
from profiles import FLUX_REPO,FLUX_COMPONENTS
from unittest.mock import patch
path=self.root/'models'/self.model_id
self.entry.update(repo=FLUX_REPO,file='Flux.2 Klein-9B_fp16_nsfw.safetensors');(path/'entry.json').write_text(json.dumps(self.entry));(path/'model.safetensors').write_bytes(b'GGUFtest')
saved=self.profiles.save(self.request());ids={};files=[]
for n,(role,info) in enumerate(FLUX_COMPONENTS.items(),1):
ident=str(n)*64;ids[role]=ident;target=self.root/'models'/ident;target.mkdir();(target/'model.safetensors').write_bytes(b'component');(target/'entry.json').write_text(json.dumps(dict(repo=info['repo'],file=info['files'][0],kind='image',size=9,revision='c'*40)));files.append(dict(name=info['files'][0],size=9))
with patch.object(self.catalog,'files',return_value=dict(files=files,revision='c'*40,gated=False,url='https://huggingface.co/example',license='test')):
self.assertTrue(self.profiles.components(self.model_id)['supported'])
self.profiles.assign(dict(id=saved['id'],revision=1,components=ids));self.profiles.image_runtime_ready=lambda:True
self.assertTrue(self.profiles.status()['profiles'][0]['runnable'])
with self.assertRaises(ValueError):self.profiles._component(self.catalog.entry(self.model_id),'vae',ids['text_encoder'])
def test_chat_medium_and_legacy_parameters(self):
self.entry['kind']='chat';(self.root/'models'/self.model_id/'entry.json').write_text(json.dumps(self.entry))
params=dict(context=160000,slots=2,threads=6,batch=2048,ubatch=256)