Skip to content

Commit

Permalink
Add test for custom workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Acly committed Nov 21, 2024
1 parent 482bc27 commit 04c7d08
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 0 deletions.
170 changes: 170 additions & 0 deletions tests/data/workflow-custom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
"3": {
"inputs": {
"seed": [
"11",
3
],
"steps": [
"14",
0
],
"cfg": [
"15",
0
],
"sampler_name": "ipndm",
"scheduler": "beta",
"denoise": 1,
"model": [
"4",
0
],
"positive": [
"6",
0
],
"negative": [
"7",
0
],
"latent_image": [
"12",
0
]
},
"class_type": "KSampler",
"_meta": {
"title": "KSampler"
}
},
"4": {
"inputs": {
"ckpt_name": "serenity_v21Safetensors.safetensors"
},
"class_type": "CheckpointLoaderSimple",
"_meta": {
"title": "Load Checkpoint"
}
},
"6": {
"inputs": {
"text": [
"13",
0
],
"clip": [
"4",
1
]
},
"class_type": "CLIPTextEncode",
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"7": {
"inputs": {
"text": "text, watermark",
"clip": [
"4",
1
]
},
"class_type": "CLIPTextEncode",
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"8": {
"inputs": {
"samples": [
"3",
0
],
"vae": [
"4",
2
]
},
"class_type": "VAEDecode",
"_meta": {
"title": "VAE Decode"
}
},
"10": {
"inputs": {
"images": [
"8",
0
]
},
"class_type": "ETN_KritaOutput",
"_meta": {
"title": "Krita Output"
}
},
"11": {
"inputs": {},
"class_type": "ETN_KritaCanvas",
"_meta": {
"title": "Krita Canvas"
}
},
"12": {
"inputs": {
"width": [
"11",
1
],
"height": [
"11",
2
],
"batch_size": 1
},
"class_type": "EmptyLatentImage",
"_meta": {
"title": "Empty Latent Image"
}
},
"13": {
"inputs": {
"name": "1. Prompt",
"type": "prompt (positive)",
"default": "",
"min": 0,
"max": 0
},
"class_type": "ETN_Parameter",
"_meta": {
"title": "Parameter"
}
},
"14": {
"inputs": {
"name": "2. Detail/2. Steps",
"type": "number (integer)",
"default": 12,
"min": 1,
"max": 10000
},
"class_type": "ETN_Parameter",
"_meta": {
"title": "Parameter"
}
},
"15": {
"inputs": {
"name": "2. Detail/4. CFG",
"type": "number",
"default": 12,
"min": 1,
"max": 10000
},
"class_type": "ETN_Parameter",
"_meta": {
"title": "Parameter"
}
}
}
22 changes: 22 additions & 0 deletions tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,28 @@ def test_translation(qtapp, client):
run_and_save(qtapp, client, job, "test_translation")


def test_custom_workflow(qtapp, client: Client):
if isinstance(client, CloudClient):
pytest.skip("Not supported in cloud")
workflow_json = test_dir / "data" / "workflow-custom.json"
workflow_dict = json.loads(workflow_json.read_text())
workflow_graph = ComfyWorkflow.import_graph(workflow_dict, client.models.node_inputs)
params = {
"1. Prompt": "a painting of a forest",
"2. Detail/2. Steps": 14,
"2. Detail/4. CFG": 3.5,
}
job = WorkflowInput(
WorkflowKind.custom,
images=ImageInput.from_extent(Extent(512, 512)),
sampling=SamplingInput("custom", "custom", 1, 1000, seed=1234),
custom_workflow=CustomWorkflowInput(workflow_graph.root, params),
)
assert job.images is not None
job.images.initial_image = Image.create(Extent(512, 512))
run_and_save(qtapp, client, job, "test_custom_workflow")


inpaint_benchmark = {
"tori": (InpaintMode.fill, "photo of tori, japanese garden", None),
"bruges": (InpaintMode.fill, "photo of a canal in bruges, belgium", None),
Expand Down

0 comments on commit 04c7d08

Please sign in to comment.