From eb80e66709aa8f6163f3906d79aa862c57fe342e Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Tue, 7 Jul 2026 05:53:48 +0000 Subject: [PATCH] Studio: apply ruff-format kwarg spacing to the diffusion review changes --- studio/backend/routes/models.py | 19 +++++++++---------- studio/backend/routes/training.py | 4 +--- .../backend/tests/test_diffusion_backend.py | 4 +--- studio/backend/tests/test_gpu_selection.py | 4 +--- studio/backend/tests/test_middleware.py | 8 ++------ 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.py index fd584acfdc..c1afc5c87e 100644 --- a/studio/backend/routes/models.py +++ b/studio/backend/routes/models.py @@ -3223,6 +3223,7 @@ def _arch_to_task(arch: Optional[str], name_hints: tuple[Optional[str], ...] = ( # GGUF (which the loader also cannot resolve) stays in the unsupported bucket rather than # advertising a GGUF that would 400 on load. from core.inference.video_families import detect_video_family + fam = detect_video_family("", override = a) if fam is None: for hint in name_hints: @@ -3250,9 +3251,7 @@ def _repo_gguf_task(repo_info) -> Optional[str]: for path in _iter_gguf_paths(Path(repo_info.repo_path)): if _is_mmproj_filename(path.name): continue - task = _arch_to_task( - _gguf_architecture(str(path)), name_hints = (repo_id, path.name) - ) + task = _arch_to_task(_gguf_architecture(str(path)), name_hints = (repo_id, path.name)) if task is not None: return task except Exception: @@ -3274,15 +3273,11 @@ def _local_model_task(model: "LocalModelInfo") -> Optional[str]: try: p = Path(path) if p.suffix.lower() == ".gguf" and p.is_file(): - return _arch_to_task( - _gguf_architecture(str(p)), name_hints = _id_hints + (p.name,) - ) + return _arch_to_task(_gguf_architecture(str(p)), name_hints = _id_hints + (p.name,)) for f in _iter_gguf_paths(p): if _is_mmproj_filename(f.name): continue - task = _arch_to_task( - _gguf_architecture(str(f)), name_hints = _id_hints + (f.name,) - ) + task = _arch_to_task(_gguf_architecture(str(f)), name_hints = _id_hints + (f.name,)) if task is not None: return task except Exception: @@ -3298,7 +3293,11 @@ def _local_model_task(model: "LocalModelInfo") -> Optional[str]: from core.inference.video import _is_trusted_video_repo from core.inference.video_families import detect_video_family for needle in (model.model_id, model.display_name, model.id): - if needle and detect_video_family(needle) is not None and _is_trusted_video_repo(path): + if ( + needle + and detect_video_family(needle) is not None + and _is_trusted_video_repo(path) + ): return _VIDEO_GEN_TASK except Exception: pass diff --git a/studio/backend/routes/training.py b/studio/backend/routes/training.py index 0d909241f0..81c1878563 100644 --- a/studio/backend/routes/training.py +++ b/studio/backend/routes/training.py @@ -2120,9 +2120,7 @@ async def import_diffusion_dataset_example( # above would treat that partial result as complete on the next retry (imported=0) # and strand the user with a truncated dataset (there is no dataset-delete flow). # Staged as a hidden sibling on the same filesystem so promotion is an atomic rename. - staging = Path( - tempfile.mkdtemp(dir = folder.parent, prefix = f".{folder.name}.import-") - ) + staging = Path(tempfile.mkdtemp(dir = folder.parent, prefix = f".{folder.name}.import-")) try: try: if entry["loader"] == "imagefolder_jsonl": diff --git a/studio/backend/tests/test_diffusion_backend.py b/studio/backend/tests/test_diffusion_backend.py index a6d45a8498..b26cf530ad 100644 --- a/studio/backend/tests/test_diffusion_backend.py +++ b/studio/backend/tests/test_diffusion_backend.py @@ -1244,9 +1244,7 @@ def test_resolve_base_repo_drops_untrusted_card_tag(monkeypatch): fam = detect_family("unsloth/FLUX.1-dev-GGUF") # A malicious card tag is ignored -> the family default base is used instead. monkeypatch.setattr(dmod, "_hf_base_model", lambda repo_id, hf_token: "attacker/evil-pipeline") - assert ( - _resolve_base_repo("attacker/flux.1-evil-GGUF", None, fam, None) == fam.base_repo - ) + assert _resolve_base_repo("attacker/flux.1-evil-GGUF", None, fam, None) == fam.base_repo # A trusted (allowlisted) card tag is still honoured, so variant resolution is not regressed. monkeypatch.setattr( dmod, "_hf_base_model", lambda repo_id, hf_token: "black-forest-labs/FLUX.1-dev" diff --git a/studio/backend/tests/test_gpu_selection.py b/studio/backend/tests/test_gpu_selection.py index 1267842b3e..3f7a98da23 100644 --- a/studio/backend/tests/test_gpu_selection.py +++ b/studio/backend/tests/test_gpu_selection.py @@ -936,9 +936,7 @@ class TestRouteErrors(unittest.TestCase): "ModelConfig", SimpleNamespace(from_identifier = lambda **_kwargs: model_config), ), - patch.object( - inference_route, "_guard_chat_load_against_training", return_value = None - ), + patch.object(inference_route, "_guard_chat_load_against_training", return_value = None), patch.object(inference_route.asyncio, "to_thread", new = _inline_to_thread), patch.object(inference_route, "_hf_offline_if_dns_dead", nullcontext), patch.object(arb, "acquire_for", lambda owner: acquired.append(owner)), diff --git a/studio/backend/tests/test_middleware.py b/studio/backend/tests/test_middleware.py index 14deb9a4c1..8f793a3be6 100644 --- a/studio/backend/tests/test_middleware.py +++ b/studio/backend/tests/test_middleware.py @@ -176,9 +176,7 @@ class TestMaxBodyMiddleware: ) path = "/api/train/diffusion/dataset" - assert any( - path.startswith(p) for p in main_module._BODY_UPLOAD_PASSTHROUGH_PREFIXES - ) + assert any(path.startswith(p) for p in main_module._BODY_UPLOAD_PASSTHROUGH_PREFIXES) cap = main_module._get_upload_passthrough_request_max_bytes(path) assert cap == upload_request_limit_bytes() # DB-aware cap + multipart overhead assert cap > default_request_body_limit_bytes() # not the plain default body cap @@ -196,9 +194,7 @@ class TestMaxBodyMiddleware: "/v1/messages", "/v1/chat/completions", ): - assert any( - path.startswith(p) for p in main_module._BODY_PROTECTED_PREFIXES - ), path + assert any(path.startswith(p) for p in main_module._BODY_PROTECTED_PREFIXES), path def test_upload_passthrough_rejects_declared_body_over_dedicated_cap(self, main_module): app = _make_protected_app(