[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2026-07-04 03:31:53 +00:00
commit 003e28730c
6 changed files with 23 additions and 16 deletions

View file

@ -356,7 +356,6 @@ def _apply_mxfp8_training(transformer, on_event) -> bool:
Never fatal: on any failure the run continues in bf16 with a warning."""
try:
from torchao.quantization import quantize_
quantize_(
transformer,
_mxfp8_training_config(),

View file

@ -911,9 +911,7 @@ async def list_local_models(
models = collect_local_models(models_root)
# Tag each model with its task so the Images picker can filter to diffusion
# (GGUF by architecture; local diffusers checkpoints by pipeline / family).
models = [
m.model_copy(update = {"task": _local_model_task(m)}) for m in models
]
models = [m.model_copy(update = {"task": _local_model_task(m)}) for m in models]
return LocalModelListResponse(
models_dir = str(models_root),

View file

@ -64,8 +64,10 @@ def test_list_images_caption_precedence(client, ds_root):
# a.png -> sidecar (an explicit edit beats the metadata row), b.png -> metadata-only,
# c.png -> none.
(folder / "metadata.jsonl").write_text(
json.dumps({"file_name": "a.png", "text": "from metadata"}) + "\n"
+ json.dumps({"file_name": "b.png", "text": "from metadata"}) + "\n",
json.dumps({"file_name": "a.png", "text": "from metadata"})
+ "\n"
+ json.dumps({"file_name": "b.png", "text": "from metadata"})
+ "\n",
encoding = "utf-8",
)
(folder / "a.txt").write_text("edited sidecar", encoding = "utf-8")

View file

@ -67,7 +67,10 @@ def test_select_lora_targets_explicit_override_wins():
base_model = "black-forest-labs/FLUX.1-dev", data_dir = "d", output_dir = "o"
).normalized()
assert cfg.lora_target_modules == DEFAULT_LORA_TARGETS
assert _select_lora_targets(cfg.lora_target_modules, _SPECS["flux.1"].lora_targets) == _FLUX_TARGETS
assert (
_select_lora_targets(cfg.lora_target_modules, _SPECS["flux.1"].lora_targets)
== _FLUX_TARGETS
)
@pytest.mark.parametrize(
@ -215,9 +218,7 @@ def test_mxfp8_training_config_falls_back_to_the_torchao_0_17_api(monkeypatch):
calls["recipe"] = recipe
return "cfg-0.17"
fake_config = SimpleNamespace(
MXFP8TrainingOpConfig = _OpConfig, MXFP8TrainingRecipe = _Recipe
)
fake_config = SimpleNamespace(MXFP8TrainingOpConfig = _OpConfig, MXFP8TrainingRecipe = _Recipe)
monkeypatch.setitem(sys.modules, "torchao.prototype.mx_formats", None)
monkeypatch.setitem(
sys.modules, "torchao.prototype.moe_training", SimpleNamespace(config = fake_config)

View file

@ -561,8 +561,10 @@ def test_diffusion_info_counts_metadata_captions(client, dataset_roots):
(folder / "c.png").write_bytes(b"x")
# a.png + b.png via metadata; a.png also has a sidecar (must count once); c.png none.
(folder / "metadata.jsonl").write_text(
json.dumps({"file_name": "a.png", "text": "cap a"}) + "\n"
+ json.dumps({"file_name": "b.png", "text": "cap b"}) + "\n",
json.dumps({"file_name": "a.png", "text": "cap a"})
+ "\n"
+ json.dumps({"file_name": "b.png", "text": "cap b"})
+ "\n",
encoding = "utf-8",
)
(folder / "a.txt").write_text("edited a", encoding = "utf-8")

View file

@ -121,7 +121,14 @@ def test_scan_models_dir_classifies_root_gguf_with_config(tmp_path):
from models.models import LocalModelInfo # noqa: E402
def _local(path, *, model_format = None, model_id = None, display_name = "m", id = "m"):
def _local(
path,
*,
model_format = None,
model_id = None,
display_name = "m",
id = "m",
):
return LocalModelInfo(
id = id,
display_name = display_name,
@ -147,9 +154,7 @@ def test_local_task_tags_diffusers_by_family_id(tmp_path):
d = tmp_path / "flux-checkpoint"
_touch(d / "flux1-dev.safetensors")
assert (
models_route._local_model_task(
_local(d, model_id = "black-forest-labs/FLUX.1-dev")
)
models_route._local_model_task(_local(d, model_id = "black-forest-labs/FLUX.1-dev"))
== "text-to-image"
)