diff --git a/studio/backend/main.py b/studio/backend/main.py index 8d67b2f02a..ca862b1ccb 100644 --- a/studio/backend/main.py +++ b/studio/backend/main.py @@ -338,8 +338,9 @@ def _scrub_validation_obj(value): # ``{"hf_xxxxx": "owner/repo"}``. Scrub string keys too so the # token does not leak through the 422 response body. return { - (_scrub_validation_obj(k) if isinstance(k, str) else k): - _scrub_validation_obj(v) + ( + _scrub_validation_obj(k) if isinstance(k, str) else k + ): _scrub_validation_obj(v) for k, v in value.items() } return value diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py index a4d8f3d5ce..ce7ddd1342 100644 --- a/studio/backend/routes/inference.py +++ b/studio/backend/routes/inference.py @@ -1681,19 +1681,11 @@ async def unload_model( llama_matches_request = ( loaded_identifier == request.model_path or loading_identifier == request.model_path - or is_registered_native_path_label( - loaded_identifier, request.model_path - ) - or is_registered_native_path_label( - loading_identifier, request.model_path - ) + or is_registered_native_path_label(loaded_identifier, request.model_path) + or is_registered_native_path_label(loading_identifier, request.model_path) ) - if ( - getattr(llama_backend, "is_active", False) - or loading_identifier - ) and ( - llama_matches_request - or not getattr(llama_backend, "is_loaded", False) + if (getattr(llama_backend, "is_active", False) or loading_identifier) and ( + llama_matches_request or not getattr(llama_backend, "is_loaded", False) ): # Round 19 P1 #6: previously this called # ``llama_backend.unload_model()`` and unconditionally diff --git a/studio/backend/tests/test_diffusion_backend.py b/studio/backend/tests/test_diffusion_backend.py index 5a94eef120..12ed6e3038 100644 --- a/studio/backend/tests/test_diffusion_backend.py +++ b/studio/backend/tests/test_diffusion_backend.py @@ -398,9 +398,11 @@ def _install_fake_diffusers(monkeypatch, *, raise_on_pipeline = False): # ``subfolder="transformer"``) so existing tests that exercise # the GGUF path do not hit a TypeError from the fake signature. fake_hub = types.ModuleType("huggingface_hub") + def _fake_download(repo_id, filename, token = None, subfolder = None, **_kwargs): sub = f"{subfolder}/" if subfolder else "" return f"/fake/{repo_id}/{sub}{filename}" + fake_hub.hf_hub_download = _fake_download monkeypatch.setitem(sys.modules, "huggingface_hub", fake_hub)