From 35cd77e6d8818bf75dec31b8bed032ab8415842b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 06:19:43 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- studio/backend/core/inference/worker.py | 7 +++++-- studio/backend/hub/services/models/cache_inventory.py | 6 +----- studio/backend/tests/test_offline_guard_refcount.py | 6 +++--- tests/studio/test_model_picker_contracts.py | 5 ++++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/studio/backend/core/inference/worker.py b/studio/backend/core/inference/worker.py index 4e01ece482..483e4fc914 100644 --- a/studio/backend/core/inference/worker.py +++ b/studio/backend/core/inference/worker.py @@ -204,7 +204,11 @@ def _resolve_lora_4bit(mc, load_in_4bit: bool) -> bool: return load_in_4bit -def _ensure_ssm_kernels(targets: list, resp_queue: Any, local_files_only: bool = False) -> bool: +def _ensure_ssm_kernels( + targets: list, + resp_queue: Any, + local_files_only: bool = False, +) -> bool: """Install the SSM kernels the given model(s) lazy-import in from_pretrained; no-op for non-SSM models, idempotent. Returns True on success; on a fatal mamba-ssm failure sends a 'loaded' failure response and returns False. Call BEFORE importing transformers, which @@ -222,7 +226,6 @@ def _ensure_ssm_kernels(targets: list, resp_queue: Any, local_files_only: bool = _ssm_status = lambda m: _send_response(resp_queue, {"type": "status", "message": m}) if local_files_only: import importlib.util - for ssm_target in dict.fromkeys(t for t in targets if t): try: needs_mamba = model_is_ssm(ssm_target) diff --git a/studio/backend/hub/services/models/cache_inventory.py b/studio/backend/hub/services/models/cache_inventory.py index 9cc835819f..0a17790bf7 100644 --- a/studio/backend/hub/services/models/cache_inventory.py +++ b/studio/backend/hub/services/models/cache_inventory.py @@ -451,11 +451,7 @@ def _repo_non_gguf_model_payload(repo_info) -> _CachedNonGgufPayload: has_checkpoint = False def _record_blob( - target: dict[str, tuple[int, float]], - file_obj, - rev_id: str, - file_name: str, - category: str, + target: dict[str, tuple[int, float]], file_obj, rev_id: str, file_name: str, category: str ) -> None: blob_path = getattr(file_obj, "blob_path", None) size = int(file_obj.size_on_disk or 0) diff --git a/studio/backend/tests/test_offline_guard_refcount.py b/studio/backend/tests/test_offline_guard_refcount.py index 1be7e1e324..933b22471e 100644 --- a/studio/backend/tests/test_offline_guard_refcount.py +++ b/studio/backend/tests/test_offline_guard_refcount.py @@ -65,9 +65,9 @@ def test_overlapping_guards_restore_only_after_last_exit(clean_env): assert os.environ.get("HF_HUB_OFFLINE") == "1" assert b.__enter__() is True a.__exit__(None, None, None) - assert os.environ.get("HF_HUB_OFFLINE") == "1", ( - "first exit must not restore while another guard is active" - ) + assert ( + os.environ.get("HF_HUB_OFFLINE") == "1" + ), "first exit must not restore while another guard is active" b.__exit__(None, None, None) assert "HF_HUB_OFFLINE" not in os.environ diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.py index aba294af69..0fd516f286 100644 --- a/tests/studio/test_model_picker_contracts.py +++ b/tests/studio/test_model_picker_contracts.py @@ -1193,7 +1193,10 @@ def test_background_picks_mirror_inventory_and_skip_installers(): # command loops (MLX and GPU paths). bootstrap = worker.split("_bootstrap_offline = contextlib.ExitStack()", 1)[1] assert bootstrap.count("_bootstrap_offline.close()") == 2 - assert "def _ensure_ssm_kernels(targets: list, resp_queue: Any, local_files_only: bool = False) -> bool:" in worker + assert ( + "def _ensure_ssm_kernels(targets: list, resp_queue: Any, local_files_only: bool = False) -> bool:" + in worker + ) ssm = worker.split("def _ensure_ssm_kernels", 1)[1] ssm = ssm.split("def _run_security_gates", 1)[0] assert "if local_files_only:" in ssm