From 16b67a2dc34c89ab23082bc6debcd2bbad100bed 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 02:17:47 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- studio/backend/hub/utils/local_snapshot.py | 1 - studio/backend/routes/inference.py | 6 +---- .../tests/test_local_snapshot_resolution.py | 23 ++++--------------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/studio/backend/hub/utils/local_snapshot.py b/studio/backend/hub/utils/local_snapshot.py index d63334ff12..504741d843 100644 --- a/studio/backend/hub/utils/local_snapshot.py +++ b/studio/backend/hub/utils/local_snapshot.py @@ -22,7 +22,6 @@ def resolve_local_snapshot_path( """ try: from huggingface_hub import snapshot_download - return snapshot_download( repo_id, local_files_only = True, diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py index bdba631a9f..0769a687d3 100644 --- a/studio/backend/routes/inference.py +++ b/studio/backend/routes/inference.py @@ -4506,11 +4506,7 @@ async def _load_model_impl( # fails over to the next candidate instead of fetching. from utils.paths import is_local_path - if ( - request.local_files_only - and not config.is_gguf - and not is_local_path(config.path) - ): + if request.local_files_only and not config.is_gguf and not is_local_path(config.path): from hub.utils.local_snapshot import resolve_local_snapshot_path local_snapshot = await asyncio.to_thread( diff --git a/studio/backend/tests/test_local_snapshot_resolution.py b/studio/backend/tests/test_local_snapshot_resolution.py index f4e2561905..ac02286f92 100644 --- a/studio/backend/tests/test_local_snapshot_resolution.py +++ b/studio/backend/tests/test_local_snapshot_resolution.py @@ -31,11 +31,7 @@ from hub.utils.local_snapshot import resolve_local_snapshot_path _REV = "0123456789abcdef0123456789abcdef01234567" -def _build_cached_repo( - cache_dir: Path, - repo_id: str, - files: dict[str, str], -) -> Path: +def _build_cached_repo(cache_dir: Path, repo_id: str, files: dict[str, str]) -> Path: """Lay out a minimal HF hub cache entry the way huggingface_hub expects: ``models--org--name/refs/main`` pointing at a snapshot directory.""" repo_dir = cache_dir / f"models--{repo_id.replace('/', '--')}" @@ -54,9 +50,7 @@ def test_cached_repo_resolves_to_its_snapshot_dir(tmp_path): "org/tiny-model", {"config.json": "{}", "model.safetensors": "weights"}, ) - resolved = resolve_local_snapshot_path( - "org/tiny-model", cache_dir = str(tmp_path) - ) + resolved = resolve_local_snapshot_path("org/tiny-model", cache_dir = str(tmp_path)) assert resolved is not None assert Path(resolved).resolve() == snapshot.resolve() @@ -72,18 +66,13 @@ def test_incomplete_snapshot_still_resolves_locally(tmp_path): "model-00001-of-00002.safetensors": "first shard only", }, ) - resolved = resolve_local_snapshot_path( - "org/half-downloaded", cache_dir = str(tmp_path) - ) + resolved = resolve_local_snapshot_path("org/half-downloaded", cache_dir = str(tmp_path)) assert resolved is not None assert Path(resolved).resolve() == snapshot.resolve() def test_uncached_repo_resolves_to_none(tmp_path): - assert ( - resolve_local_snapshot_path("org/never-downloaded", cache_dir = str(tmp_path)) - is None - ) + assert resolve_local_snapshot_path("org/never-downloaded", cache_dir = str(tmp_path)) is None def test_resolution_never_uses_the_network(tmp_path, monkeypatch): @@ -97,6 +86,4 @@ def test_resolution_never_uses_the_network(tmp_path, monkeypatch): monkeypatch.setattr(socket.socket, "connect", _no_network) _build_cached_repo(tmp_path, "org/offline-ok", {"config.json": "{}"}) assert resolve_local_snapshot_path("org/offline-ok", cache_dir = str(tmp_path)) - assert ( - resolve_local_snapshot_path("org/absent", cache_dir = str(tmp_path)) is None - ) + assert resolve_local_snapshot_path("org/absent", cache_dir = str(tmp_path)) is None