Repository navigation
Studio: remove private helpers and constants that nothing uses - #15696
Merged
Merged
Conversation
…LX code [skip ci]
danielhanchen
added a commit
to Datta0/unsloth-staging-3
that referenced
this pull request
Oct 28, 2026
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This was referenced Oct 28, 2026
danielhanchen
added a commit
that referenced
this pull request
Oct 28, 2026
…ugh run_pwsh (#15758) ## Summary `Repo tests (CPU, studio)` fails on main, so it is red on every recent staging CI run (#15680, #15696, #15716, #15723 and others). Of its 6 failures, 4 are tests that no longer match intentional changes; this PR fixes those. The other 2 are real product slips on the login screen and are fixed separately. **Media picker contracts (3 failures).** #15726 lined the Images, Audio and Video model pickers up with Chat: - The picker now uses `className="ml-1.5 max-w-full overflow-hidden !pl-2.5 !pr-1.5 !h-[var(--studio-chat-control-height,34px)]"`. - It no longer sets a `triggerLabelClassName` override. `tests/studio/test_desktop_reliability_frontend_contract.py` still pinned the old class string and the old label override, and counted two scaled `!h-[calc(34px*var(--ui-space-scale,1))]` literals on the Images and Video pages (and one on Audio) that are now the shared token: ``` images-page.tsx states 1 scaled !h-34px, not 2 assert 'className="!h-[34px] max-w-full gap-1 ...' in header ``` **PowerShell spawn (1 failure).** `tests/python/test_installer_compile_bytecode.py:271` (from #15646) starts PowerShell with `subprocess.run`. `tests/studio/test_pwsh_calls_use_the_shared_runner.py` forbids that, because direct spawns share one PowerShell startup cache across xdist workers and can die at startup. ## Change - **`test_desktop_reliability_frontend_contract.py`:** - The Images and Audio header contracts assert the new picker class (`_MEDIA_PICKER_CLASS`), and that the label is not overridden, so the trigger reads like Chat's. - The scale table's `!h-34px` counts drop to what the pages still state literally: Images 1, Audio 0, Video 1. The "no bare `!h-[34px]`" half of that check is unchanged. - New test `test_the_media_pickers_take_chats_scaled_control_height`: all three pages use the picker class, and `index.css` still defines `--studio-chat-control-height` as `calc(Npx * var(--ui-space-scale, 1))`. This keeps the original point of the scale check, a pill that grows with the UI scale, attached to the token the height now comes from. - **`test_installer_compile_bytecode.py`:** the PowerShell case runs through `run_pwsh` from `tests/_shared/unsloth_pwsh_runner.py`, with the same argv and keyword arguments. ## Testing - These three files: 80 passed (pwsh is installed here, so the PowerShell cases really ran). On main, the same tests fail 4. - **Sabotage:** with `--studio-chat-control-height` changed to a bare `33px`, the new scaling test fails.
danielhanchen
marked this pull request as ready for review
October 28, 2026 12:30
danielhanchen
added a commit
that referenced
this pull request
Oct 28, 2026
…ashing it (#15763) ## Summary The macOS `Chat UI, API, Update and GGUF inference` job fails on unrelated PRs (seen on #15696 and #15673 today) after 50 to 75 minutes in Studio setup: ``` [node-prebuilt] downloading https://nodejs.org/dist/v24.22.1/node-v24.22.1-darwin-arm64.tar.gz Downloading node-v24.22.1-darwin-arm64.tar.gz: 12.1% (6.1 MiB/50.6 MiB) at 1.6 KiB/s [node-prebuilt] node-v24.22.1-darwin-arm64.tar.gz checksum mismatch 1/2: expected=89c6... actual=8014... ... [node-prebuilt] prebuilt unavailable: node-v24.22.1-darwin-arm64.tar.gz checksum mismatch after retry error studio setup failed (exit code 1) ``` The archive was never tampered with: it was 6.1 MiB of a 50.6 MiB body. Two installer bugs turn a flaky connection into that: 1. **Truncated bodies are accepted.** `http.client.HTTPResponse.read(amt)` returns `b""` when the server closes before `Content-Length` bytes arrive, without raising `IncompleteRead` (CPython leaves this as a known compatibility trade-off). The copy loops in `install_node_prebuilt.download_file`, `prebuilt_core.download_file` and `prebuilt_core.download_bytes` stop at the first empty read, so a short file is written out and hashed. For Node that surfaces as a misleading checksum mismatch; for a llama.cpp asset with no published digest the short archive goes straight to the extractor. 2. **A trickle never times out.** The 120 s socket timeout is per read, so a connection that keeps delivering a few bytes a second holds an attempt open indefinitely (1.6 KiB/s above, over 30 minutes per attempt). ## Change - `prebuilt_core.copy_response_body`: one body-copy helper used by all three loops. - Raises `TruncatedDownload` (a subclass of `http.client.IncompleteRead`) when the body ends short of `Content-Length`. - Raises `StalledDownload` (a `TimeoutError`) when a 60 s window brings under 256 KiB, about 4 KiB/s, and the body is not yet complete. - Reads a real `http.client.HTTPResponse` with `read1`, which returns what one receive brings. `read(n)` waits for all n bytes, so on a trickle it would block for hours and the window check would never run. - Both exceptions are already classified as retryable by `is_retryable_url_error` in both modules, so the existing retry loops reconnect instead of hashing a partial file or waiting on a dead connection. Bodies without `Content-Length` (chunked) keep their current behaviour; http.client already raises on a cut chunked body. ## Testing - New `tests/studio/install/test_download_truncation_and_stall.py` (11 tests) runs against a real local HTTP server, because the `read(amt)` EOF behaviour is what is under test and a `BytesIO` double cannot reproduce it: - a body closed at 25% raises a retryable `TruncatedDownload`; - `download_file` (Node and llama.cpp paths) and `download_bytes` reconnect and finish with the full payload; - a server that truncates every attempt is refused with no partial file left behind; - a trickling body is abandoned, a slow but moving one is not, and a window closing on the final byte is not a stall. - a real server sending the full `Content-Length` then one byte every 50 ms is abandoned within the (shortened) window, and `download_file` reconnects past it on both paths. - Sabotage: with only the truncation check removed, 5 tests fail; with only the stall check removed, the trickle test fails; with plain `read` instead of `read1`, the three real-trickle tests fail (the call blocks until the server gives up). - `tests/studio/install` base vs head on this host: identical failing test IDs (21, all pre-existing on main here), 10274 passed at base and 10282 with this change (the 8 new tests). - Real download through the new path: `node-v24.22.1-linux-x64.tar.gz` (55.6 MiB) from nodejs.org verified against the pinned sha256 at 378 MiB/s, so the smaller reads cost nothing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Studio: remove private helpers and constants that nothing uses
Removes 25 private (
_-prefixed) functions, constants and one method across the Studio backend and the CLI that have no reference anywhere. Public names are kept even when unused. 119 lines deleted, nothing added, no behaviour change: same routes, same CLI help, same OpenAPI schema.What is removed
Grouped by area (one commit each):
_list_hf_data_files,_gguf_files_for_pick,_discard_pooled._GEMMA_CHANNEL_START,_remove_spans,_SHADOWING_FLAGS,_DISPATCH_DRAIN_TIMEOUT,_largest_leaf._SAGE_DTYPE_NAMES,_TIER_DEFAULT,_all_wide,_BLOCK_LIST_ATTRS,_NATIVE_EXTS,_DIFFUSERS_EXTS,_source_shards_in,_connection_failed,_TRAIN_DENY_NVFP4_REASON,_CACHE_T,_component_undo,_UNRESOLVED_REVISION._public_verdict,_CACHE_SPLIT_RE,_RANGE_TIMEOUT,_without_partial_utf8_edges._read_yaml_object.Kept on purpose: every unused public name (the earlier draft also removed eleven unused public helpers such as
bearer_is_valid_api_key,delete_manifest,download_gguf_file,TRANSFORMERS_5_VERSIONandwindows_root; they are restored), framework and protocol hooks (ast.NodeVisitor.visit_*, accelerateModelHook.detach_hook, picklepersistent_id), the separately installable data-designer plugins, and constants with side effects.How unused was established
getattr,import_module, subscripts with an f-string or concatenated key) were collected as prefix / suffix pairs; every name a pair could build was checked by reading the construction site.import mainwith its sorted route list,unsloth --helpplus every subcommand's--help, and the fullapp.openapi()JSON are identical on main and this PR.Tests
tests/studioandunsloth_clitests named after a touched module: 1211 passed, 37 skipped on both.py_compileon Python 3.9 and 3.10 for every touched file.Not covered
Kept on purpose
Unused names in security, sandbox, auth, hardware detection, installer, MLX and transformers-5 sidecar code are kept, so this PR touches none of those files:
_LOGIN_LOCKOUT_SECONDS,_request_has_desktop_access_token,_TRAVERSAL_TOKEN_RE,_RELATIVE_PATH_TOKEN_RE,_CD_TARGET_RE,_TRACER_LAUNCHERS,_INLINE_CODE_FLAGS,_AUTO_EXEC_MCP_RUNTIME_NOUN_RE,_project_exists,_auto_map_py,_valid_sha256,_reconcile_primary_rocm_unified_memory,_nounits,_host_has_windows_hip_prebuilt_gfx,_DENSE_TYPES,_mlx_requested,_VENV_T5_PACKAGES,_venv_t5_is_valid,_ensure_venv_t5_exists,_JOB_IDLE,_is_under,_parse_installed_at,_reset_host_fingerprint. Some of them may mark a check that was meant to be applied; that is worth a separate look, not a silent delete.