6969])
7070def test_workflow (workflow , script ):
7171 with open (Path (__file__ ).parent / workflow ) as f :
72- assert transpile .WorkflowToScriptTranspiler (f .read ()).to_script () == script
72+ assert transpile .WorkflowToScriptTranspiler (f .read ()).to_script () == script
73+
74+ @pytest .mark .parametrize ('workflow, script' , [
75+ ('default.json' ,
76+ r"""model, clip, vae = CheckpointLoaderSimple(ckpt_name='v1-5-pruned-emaonly.ckpt')
77+ conditioning = CLIPTextEncode(text='beautiful scenery nature glass bottle landscape, , purple galaxy bottle,', clip=clip)
78+ conditioning2 = CLIPTextEncode(text='text, watermark', clip=clip)
79+ latent = EmptyLatentImage(width=512, height=512, batch_size=1)
80+ latent = KSampler(model=model, seed=156680208700286, steps=20, cfg=8, sampler_name='euler', scheduler='normal', positive=conditioning, negative=conditioning2, latent_image=latent, denoise=1)
81+ image = VAEDecode(samples=latent, vae=vae)
82+ SaveImage(images=image, filename_prefix='ComfyUI')
83+ """ ),
84+ ('bypass.json' ,
85+ r"""image, _ = LoadImage(image='ComfyUI_temp_rcuxh_00001_.png')
86+ image2 = ImageScaleToSide(image=image, side_length=1024, side='Longest', upscale_method='nearest-exact', crop='disabled')
87+ PreviewImage(images=image2)
88+ image3, _ = CRUpscaleImage(image=image2, upscale_model='8x_NMKD-Superscale_150000_G.pth', mode='rescale', rescale_factor=2, resize_width=1024, resampling_method='lanczos', supersample='true', rounding_modulus=8)
89+ segs = ImpactMakeTileSEGS(image=image3, bbox_size=600, crop_factor=1.5, min_overlap=200, max_overlap=100, sub_batch_size_for_dilation=0, filter_segs_dilation='Reuse fast', mask_irregularity=None, irregular_mask_mode=None)
90+ # _ = SEGSPreview(segs=segs, alpha_mode=True, falloff=0.1, image=image3)
91+ image4 = image3
92+ PreviewImage(images=image4)
93+ segs2 = segs
94+ model, clip, vae = CheckpointLoaderSimple(ckpt_name=r'XL\turbovisionxlSuperFastXLBasedOnNew_alphaV0101Bakedvae.safetensors')
95+ lora_stack, _ = CRLoRAStack(switch_1='On', lora_name_1=r'xl\LCMTurboMix_LCM_Sampler.safetensors', model_weight_1=1, clip_weight_1=1, switch_2='On', lora_name_2=r'xl\xl_more_art-full_v1.safetensors', model_weight_2=1, clip_weight_2=1, switch_3='On', lora_name_3=r'xl\add-detail-xl.safetensors', model_weight_3=1, clip_weight_3=1, lora_stack=None)
96+ model, clip, _ = CRApplyLoRAStack(model=model, clip=clip, lora_stack=lora_stack)
97+ conditioning = CLIPTextEncode(text='Shot Size - extreme wide shot,( Marrakech market at night time:1.5), Moroccan young beautiful woman, smiling, exotic, (loose hijab:0.1)', clip=clip)
98+ conditioning2 = CLIPTextEncode(text='(worst quality, low quality, normal quality:2), blurry, depth of field, nsfw', clip=clip)
99+ basic_pipe = ToBasicPipe(model=model, clip=clip, vae=vae, positive=conditioning, negative=conditioning2)
100+ image5, _, _, _ = DetailerForEachPipe(image=image3, segs=segs2, guide_size=1024, guide_size_for=True, max_size=1024, seed=403808226377311, steps=10, cfg=3, sampler_name='lcm', scheduler='ddim_uniform', denoise=0.1, feather=50, noise_mask=True, force_inpaint=True, basic_pipe=basic_pipe, wildcard='', cycle=0, inpaint_model=1, noise_mask_feather=None, scheduler_func_opt=None, detailer_hook=True, refiner_ratio=50)
101+ PreviewImage(images=image5)
102+ PreviewImage(images=image)
103+ """ ),
104+ ('rgthree-comfy.json' ,
105+ r"""model, clip, vae = CheckpointLoaderSimple(ckpt_name='v1-5-pruned-emaonly.ckpt')
106+ # _ = CLIPTextEncode(text='n', clip=clip)
107+ conditioning = CLIPTextEncode(text='p', clip=clip)
108+ latent = EmptyLatentImage(width=512, height=512, batch_size=1)
109+ latent = KSampler(model=model, seed=0, steps=20, cfg=8, sampler_name='euler', scheduler='normal', positive=conditioning, negative=conditioning, latent_image=latent, denoise=1)
110+ image = VAEDecode(samples=latent, vae=vae)
111+ SaveImage(images=image, filename_prefix='ComfyUI')
112+ """ ),
113+ ('SplitSigmasDenoise.api.json' ,
114+ r"""noise = DisableNoise()
115+ width, height, _, _, _, empty_latent, _ = CRAspectRatio(width=512, height=768, aspect_ratio='custom', swap_dimensions='Off', upscale_factor=1, prescale_factor=1, batch_size=1)
116+ model = UNETLoader(unet_name='flux1-dev.safetensors', weight_dtype='fp8_e4m3fn')
117+ model = LoraLoaderModelOnly(model=model, lora_name='a.safetensors', strength_model=0.7000000000000001)
118+ model = LoraLoaderModelOnly(model=model, lora_name='b.safetensors', strength_model=0.7000000000000001)
119+ model = ModelSamplingFlux(model=model, max_shift=1.1500000000000001, base_shift=0.5, width=width, height=height)
120+ clip = DualCLIPLoader(clip_name1='t5.safetensors', clip_name2='clip_l.safetensors', type='flux')
121+ conditioning = CLIPTextEncode(text='prompt text', clip=clip)
122+ conditioning = FluxGuidance(conditioning=conditioning, guidance=3.5)
123+ guider = BasicGuider(model=model, conditioning=conditioning)
124+ sampler = KSamplerSelect(sampler_name='deis')
125+ sigmas = BasicScheduler(model=model, scheduler='beta', steps=30, denoise=1)
126+ sigmas, low_sigmas = SplitSigmasDenoise(sigmas=sigmas, denoise=0.4)
127+ noise2 = RandomNoise(noise_seed=149684926930931)
128+ empty_latent, _ = SamplerCustomAdvanced(noise=noise2, guider=guider, sampler=sampler, sigmas=sigmas, latent_image=empty_latent)
129+ empty_latent = InjectLatentNoise(latent=empty_latent, seed=49328841076664, strength=0.3, normalize='true', average=None)
130+ empty_latent, _ = SamplerCustomAdvanced(noise=noise, guider=guider, sampler=sampler, sigmas=low_sigmas, latent_image=empty_latent)
131+ vae = VAELoader(vae_name='ae.safetensors')
132+ image = VAEDecode(samples=empty_latent, vae=vae)
133+ SaveImage(images=image, filename_prefix='ComfyUI')
134+ """ )
135+ ])
136+ def test_workflow_with_keyword_args (workflow , script ):
137+ with open (Path (__file__ ).parent / workflow ) as f :
138+ assert transpile .WorkflowToScriptTranspiler (f .read (), use_keyword_args = True ).to_script () == script
0 commit comments