Repository navigation
Fold duplicated backend, hub and package tests into parametrized runs - #10499
Conversation
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. |
…arametrized cases
82e5224 to
17cbce0
Compare
|
@codex security review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ 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". |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ 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". |
The parametrize folds shortened or reworded some case IDs, so the pre-fold test name could no longer be recovered from the node ID by grep. Restore it: every folded case now carries the original test name minus its test_ prefix, and originals that were themselves parametrized carry that name plus their original case label. IDs only. No test input, expected value or assertion is changed. Collected node id count is unchanged at 57741.
_shared_setup_4 built its knowledge base inside `with _connection() as conn` and then returned that connection. _connection is a `closing(...)`, so the handle is already closed by the time the caller sees it. All four call sites happen to shadow it with their own `with _connection() as conn` before any use, which is why nothing fails today, but the helper is new here and handing a closed connection to whoever writes the next test against it is a trap. Return the routes module alone and unpack a single value at the call sites.
_shared_setup_7 built its zip inside `with zipfile.ZipFile(archive, "w") as zf` and returned that handle; _shared_setup_10 did the same with the file object from `with open(...) as f`. Both are closed by the time the caller sees them. Nothing fails today because the four zip call sites immediately shadow `zf` with their own `with zipfile.ZipFile(archive) as zf`, and the three record call sites never touch `f` at all. Both helpers are new here, so this is a trap we would be creating rather than inheriting. Return the archive path and the root directory alone, and unpack a single value at the seven call sites.
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ 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". |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ 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". |
Drop the generated per-helper setup narration and collapse multi-line case notes to one line where a single line carries the same fact. Comments only; the parsed AST of every touched file is unchanged.
…ose and in keys Resolves the merge with main. Two files conflicted: - tests/data/refactor_guard/patch_targets.json: took main's side under utils.hf_cache_settings.active_hf_hub_cache. This PR touches neither that setting nor test_rag_embeddings.py. - tests/test_safetensors_tool_loop.py: main folded these into parametrized runs in #10499, so three of the four conflicts were main deleting tests whose ids it preserved as parametrize ids. Took the deletion. The fourth was a genuine union of this PR's guard class and main's DeepSeek helpers; kept both. Main's fold re-encoded the pre-PR expectation that a markerless execution-class rehearsal promotes, so six of its new cases asserted that python[ARGS]{...} still fires. Applied the substitution this PR had already made to the individual tests before the merge: a benign name in place of the blocked one. Also fixes two ways a blocked bare-JSON body stayed readable: - The masking walk only followed a chain from the START of the text, so "Answer:\n{"name":"terminal",...}" left it unwalked and the wrapper quoted inside the blocked body was reconsidered on its own and executed as python. It now resumes at the next brace, but only across inert prose: markup in the gap owns the object behind it, and resuming past a trusted marker masked a legitimately marked call's arguments. - Only values were masked, so tool markup spelled into a top-level KEY was promoted out of a truncated object the balanced-leading-object guard cannot claim. Key contents are masked as data too; the classification keys stay readable so the call still reads as blocked downstream. Corpus of 3430 cases: parse_tool_calls_from_text and strip_tool_markup are byte-identical, and the 18 changed _mask_blocked_bodies cases are all prose ahead of a blocked terminal call. Baselines merged by hand for the three new symbols and the four hashes that moved.
What this does
Removes 3,888 lines across five test areas without changing what any test checks. Third of three chunks of
studio/backend/tests(filestest_passthrough_healing.pyonward), plusstudio/backend/hub/tests,tests/python,tests/kaggleandunsloth/kernels/moe/tests.105 files changed, 8,321 insertions, 12,209 deletions.
The figures above are measured against the current merge base, which has moved with
pre-commit.cireformatting and merges ofmain.Where the lines went
@pytest.mark.parametrize, about 3,400 lines. Node ids change by design here:test_foobecomestest_fold[foo]. Every folded case carries the original test name minus itstest_prefix as the param id, so each case stays individually addressable and the original name is recoverable by grep. For the few originals that were already parametrized, the id is that name plus the original case label. Measured against currentmain, 481 node ids are renamed this way and 482 appear in their place (one original asserted two things and became two cases), so the total collected goes from 57,740 to 57,741 and no case is dropped.test_safetensors_tool_loop.pyrepeated the DeepSeek full-width and Kimi ASCII tool-call envelopes hundreds of times;_ds_call,_kimi_calland_kimi_sectionplus the_DS_*constants removed 328 lines from that file alone.symtablefree-variable analysis so nothing is captured wrongly, and repeated try/finally save-restore folded into acontextlib.contextmanager(_restores_hardware_verdict, 13 call sites).Example from
studio/backend/hub/tests/test_dataset_local_options.py:Biggest files:
hub/tests/test_model_services.py-655,test_sandbox_files_and_storage_roots.py-574,test_safetensors_tool_loop.py-328,test_video_backend.py-273,test_sd_cpp_install.py-135.How I checked coverage did not move
A detached base worktree was built at the base commit and identical commands run in both trees.
test_transformers_version.py315 to 316.tests/pythonandtests/kagglefiles: 2 failed / 1,501 passed / 74 skipped / 10 deselected at both revisions, same two node ids.pytest.mark.skipifcount unchanged at 56. No marker added or removed, no-m gpu.Folding copy-pasted tests into parametrize necessarily lowers the raw
def test_count (7,121 to 6,720) andassertcount, which is why the collected node count is the invariant that matters here rather than the function count.Because much of the work was script-driven, every comment and every string or bytes literal value in all changed files was diffed against base, then re-checked at word level for whether each vanished comment's content survives elsewhere in the file. Two genuine losses were found and restored: a
Finding 5:provenance tag, and three inline fuzz-input labels intest_tool_call_parser_strict.py. One unintended prose edit (behaviorrewritten tobehaviour) was reverted.What I threw away
A fuzzy extraction pass worth about 1,677 lines was abandoned entirely after the literal audit showed it had parameterized assertion literals and two payload values had vanished from
test_safetensors_tool_loop.py.Eight files were reverted after automated passes broke them, several later redone by hand. Fourteen more were reverted because the change was net zero or negative and was pure churn.
Mechanical comment stripping across these areas measured at only about 650 lines and was judged not worth the risk.
tests/kaggleis 26.6% comments, but sampling shows they are measured ladder-probe evidence and cost-of-getting-it-wrong notes, so that area is nearly untouched.Merging
_FakeWanPipeSingleand_FakeWanPipeMoEintest_video_backend.pywas rejected: their__call__signatures differ deliberately, so that the cfg2 gate must not threadguidance_scale_2.Style
ast.unparserewrites quote style and keyword spacing, which would have put gratuitous churn in the diff. Atokenize-based pass scoped strictly to the 6,717 added line numbers normalised it back, skipping any literal containing a nested quote, apostrophe, escape or DeepSeek marker character, and comparingast.dumpbefore and after per file as proof no literal value moved. Single-quoted strings 1,370 to 1,358 and unspaced keyword arguments 1,375 to 1,361, both now slightly below base.Local test state
Pre-existing on this box and identical at base and head: 3 collection errors in
unsloth/kernels/moe/tests(No module named 'grouped_gemm'), 3 backend files failing to collect (No module named 'utils.paths.path_utils'),test_video_backend.pyat 90 failed standalone, 2 failures intests/python, and 2 intest_utils.pythat only appear in a combined multi-file run from cross-file GPU mock pollution.I am not claiming a clean local suite. The claim is that the failure set is identical with and without this change.