[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
9b8132ec9e
commit
d927bf155c
2 changed files with 15 additions and 4 deletions
|
|
@ -893,7 +893,10 @@ class SdCppDiffusionBackend:
|
|||
lora_stage = Path(server_lora_dir) / f"gen_{os.urandom(6).hex()}"
|
||||
materialized = diffusion_lora.materialize_native_dir(lora_resolved, lora_stage)
|
||||
lora_payload = [
|
||||
{"path": f"{lora_stage.name}/{Path(m.path).name}", "multiplier": float(m.weight)}
|
||||
{
|
||||
"path": f"{lora_stage.name}/{Path(m.path).name}",
|
||||
"multiplier": float(m.weight),
|
||||
}
|
||||
for m in materialized
|
||||
]
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -691,7 +691,11 @@ def _fake_materialize(resolved, dest):
|
|||
return out
|
||||
|
||||
|
||||
def _patch_lora(monkeypatch, resolved, supported = True):
|
||||
def _patch_lora(
|
||||
monkeypatch,
|
||||
resolved,
|
||||
supported = True,
|
||||
):
|
||||
from core.inference import diffusion_lora as dl
|
||||
|
||||
monkeypatch.setattr(dl, "supports_lora", lambda **k: supported)
|
||||
|
|
@ -706,7 +710,9 @@ def test_generate_oneshot_applies_loras_via_prompt_tags(monkeypatch):
|
|||
|
||||
eng = _FakeEngine()
|
||||
b = _loaded_backend(engine = eng) # mode = "oneshot"
|
||||
_patch_lora(monkeypatch, [dl.ResolvedLora("id1", "myalias", "/x/a.safetensors", "safetensors", 0.8)])
|
||||
_patch_lora(
|
||||
monkeypatch, [dl.ResolvedLora("id1", "myalias", "/x/a.safetensors", "safetensors", 0.8)]
|
||||
)
|
||||
b.generate(prompt = "a fox", steps = 4, seed = 1, loras = [("id1", 0.8)])
|
||||
_, params, _, _ = eng.calls[0]
|
||||
assert params.lora_dir is not None and params.lora_apply_mode == "auto"
|
||||
|
|
@ -725,7 +731,9 @@ def test_generate_server_stages_loras_and_sends_structured_field(monkeypatch, tm
|
|||
servers: list = []
|
||||
_run_server_load(monkeypatch, b, servers)
|
||||
servers[0].lora_dir = str(tmp_path)
|
||||
_patch_lora(monkeypatch, [dl.ResolvedLora("id1", "myalias", "/x/a.safetensors", "safetensors", 0.7)])
|
||||
_patch_lora(
|
||||
monkeypatch, [dl.ResolvedLora("id1", "myalias", "/x/a.safetensors", "safetensors", 0.7)]
|
||||
)
|
||||
b.generate(prompt = "x", steps = 4, seed = 1, batch_size = 1, loras = [("id1", 0.7)])
|
||||
payload = servers[0].payloads[0]
|
||||
assert "lora" in payload and len(payload["lora"]) == 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue