Defaults an administrator can actually set
There were none. `workflow.DEFAULTS` was the only source, so 512x512, euler and twenty steps were what every instance got whatever card it was running on -- and 512 square on an SDXL checkpoint is precisely what the tool's own description warns produces duplicated limbs. The two ways round it were both bad: bake literals into a template where the placeholders should be, or write prose in the instructions box and hope. Three rungs now, most specific winning, with DEFAULTS staying underneath as the floor so an instance that sets nothing behaves exactly as it did and a floor improved in code still reaches everybody. An empty box is "no opinion" rather than zero, which matters: read as a number it would set every instance to zero steps, and ComfyUI refuses that in a way that looks like a broken model. The right control for each, because a text box is wrong for most of them. The samplers and schedulers were already being discovered by the Test button, stored, and read by nothing at all -- they are the pickers now. A stored value missing from the list is kept as an option anyway, or opening this page and pressing Save would silently clear a working setting. Checkpoints are chosen rather than typed, and the instance default is a rung of its own instead of "whatever happens to be first in a textarea somebody filled in some order". And batch, at last: `batch_size` was a literal 1 in the base template, so an administrator whose card can comfortably make four had no way of saying so. Deliberately not something a model may set -- one asking for six because it is unsure is the exact cost this must not invite. The tool's schema restates the defaults it quotes. Every "Default 20." in there was written when there was one set of defaults in the world; left alone, an instance drawing at 1024 would go on telling the model 512, and the model reasons from that sentence rather than ignoring it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -270,3 +270,124 @@ def test_only_an_administrator_can_reach_it(client: TestClient, db, registered):
|
||||
|
||||
assert client.get("/admin/images").status_code in (302, 303, 403, 404)
|
||||
assert client.post("/admin/images/workflows", data={}).status_code in (302, 303, 403, 404)
|
||||
|
||||
|
||||
# --- The defaults card ----------------------------------------------------------
|
||||
def test_the_defaults_are_saved_and_clamped(client, db, registered):
|
||||
"""Clamped at the save as well as on the way out. A number stored by an
|
||||
earlier version, or written straight into the settings row, still has to be
|
||||
safe when a generation reads it."""
|
||||
from lembas.services import settings_store
|
||||
|
||||
client.post(
|
||||
"/admin/images",
|
||||
data={
|
||||
"base_url": "http://comfy.test",
|
||||
"api_key": "",
|
||||
"timeout": "600",
|
||||
"checkpoints": "sd.safetensors",
|
||||
"default_steps": "9000",
|
||||
"default_width": "1024",
|
||||
"default_cfg": "5.5",
|
||||
"default_sampler": "dpmpp_2m",
|
||||
"default_batch": "4",
|
||||
},
|
||||
follow_redirects=False,
|
||||
)
|
||||
|
||||
values = settings_store.images(db)
|
||||
assert values["default_steps"] == 150 # the ceiling, not 9000
|
||||
assert values["default_width"] == 1024
|
||||
assert values["default_cfg"] == 5.5
|
||||
assert values["default_sampler"] == "dpmpp_2m"
|
||||
assert values["default_batch"] == 4
|
||||
|
||||
|
||||
def test_an_empty_default_stays_empty_rather_than_becoming_zero(client, db, registered):
|
||||
"""The empty string is how an administrator says "no opinion", which
|
||||
`workflow.resolve` reads as "fall through to the built-in". Read as a number
|
||||
it would set the instance to zero steps."""
|
||||
from lembas.services import settings_store
|
||||
|
||||
client.post(
|
||||
"/admin/images",
|
||||
data={"base_url": "http://comfy.test", "api_key": "", "timeout": "600"},
|
||||
follow_redirects=False,
|
||||
)
|
||||
|
||||
values = settings_store.images(db)
|
||||
assert values["default_steps"] == ""
|
||||
assert values["default_cfg"] == ""
|
||||
|
||||
|
||||
def test_saving_the_page_does_not_clear_the_discovered_lists(client, db, registered):
|
||||
"""They belong to whatever ComfyUI was tested, and a save that only changed
|
||||
the instructions box has no opinion about them. The sampler picker is built
|
||||
from them, so clearing them would empty it."""
|
||||
from lembas.services import settings_store
|
||||
|
||||
settings_store.update(
|
||||
db, {"samplers": ["euler", "dpmpp_2m"], "schedulers": ["normal"]},
|
||||
key=settings_store.IMAGES,
|
||||
)
|
||||
db.commit()
|
||||
|
||||
client.post(
|
||||
"/admin/images",
|
||||
data={"base_url": "http://comfy.test", "api_key": "", "timeout": "600"},
|
||||
follow_redirects=False,
|
||||
)
|
||||
|
||||
values = settings_store.images(db)
|
||||
assert values["samplers"] == ["euler", "dpmpp_2m"]
|
||||
|
||||
|
||||
def test_the_sampler_picker_offers_what_comfyui_advertised(client, db, registered):
|
||||
"""Discovered, stored, and — until now — read by nothing at all. There are
|
||||
forty-odd samplers and spelling one wrong is a refused workflow, so it is
|
||||
picked rather than typed."""
|
||||
from lembas.services import settings_store
|
||||
|
||||
settings_store.update(
|
||||
db, {"samplers": ["euler", "dpmpp_2m_sde"], "schedulers": ["karras"]},
|
||||
key=settings_store.IMAGES,
|
||||
)
|
||||
db.commit()
|
||||
|
||||
body = client.get("/admin/images").text
|
||||
|
||||
assert 'name="default_sampler"' in body
|
||||
assert "dpmpp_2m_sde" in body
|
||||
assert "karras" in body
|
||||
|
||||
|
||||
def test_a_stored_sampler_survives_a_list_that_does_not_have_it(client, db, registered):
|
||||
"""Otherwise opening the page and saving it silently clears a working
|
||||
setting, because the select had no option matching the stored value."""
|
||||
from lembas.services import settings_store
|
||||
|
||||
settings_store.update(
|
||||
db, {"samplers": ["euler"], "default_sampler": "some_custom_sampler"},
|
||||
key=settings_store.IMAGES,
|
||||
)
|
||||
db.commit()
|
||||
|
||||
body = client.get("/admin/images").text
|
||||
|
||||
assert "some_custom_sampler" in body
|
||||
|
||||
|
||||
def test_the_workflow_editor_says_what_each_placeholder_resolves_to(client, db, registered):
|
||||
"""A legend listing names answers "what may I write"; the question somebody
|
||||
has in front of a workflow that came out wrong is "what happens if I leave
|
||||
this out"."""
|
||||
from lembas.services import settings_store
|
||||
|
||||
settings_store.update(db, {"default_width": 1024}, key=settings_store.IMAGES)
|
||||
db.commit()
|
||||
|
||||
body = client.get("/admin/images/workflows/new").text
|
||||
|
||||
assert "ckpt_name" in body # the name that is not the placeholder's
|
||||
assert "sampler_name" in body
|
||||
assert "1024" in body # the resolved default, beside {{width}}
|
||||
|
||||
Reference in New Issue
Block a user