Move the studiobench attribution config in with the harness (#10100)

A top-level attribution/ directory holding one file is repository clutter, and
the file has no business being at the root: it is a vite config used by exactly
one thing, the studiobench harness under tests/studio/studiobench, whose
bridge_build.py is the only referrer in the tree.

Three things fall out of the move for free.

It stops shipping. attribution/ was a tracked top-level directory, so
setuptools-scm put the config in the sdist of every release; under tests/ the
prune from #10060 covers it. The published sdist was carrying a build config
whose consumer, after #10060, no longer ships with it.

It gains CI. studiobench-ci.yml triggers on tests/studio/studiobench/**, so a
change to this config now runs the suite. Nothing anywhere triggered on
attribution/, which is how this file managed to break twice inside its own
introducing PR (#9296).

Module resolution is unchanged. The config resolves its plugins through
createRequire anchored at studio/frontend/package.json precisely because no
ancestor of its own directory has a node_modules. That is still true of the new
location, so the reason the anchoring exists survives intact. studio/frontend
was the other obvious home and is the wrong one: package-data already globs
frontend/*.ts, so parking it there would ship it inside the wheel.

Verified by building the frontend with the config from both paths, against the
same node_modules:

  before  525 js, 509 maps, 522 banner hits, 0 sourceMappingURL, 2430/2506 names
  after   525 js, 509 maps, 522 banner hits, 0 sourceMappingURL, 2430/2506 names

Identical, including the SHA over the emitted relative paths -- and vite names
chunks by content hash, so an identical path set means identical bytes. The
built dist stays gitignored (the bare dist/ rule is unanchored). Both artifacts
build with no attribution entry and no tests path segment. Suite green:
1400 passed, 155 skipped, ruff clean.

Co-authored-by: danielhanchen <elliegouldingstuff@gmail.com>
This commit is contained in:
Daniel Han 2026-08-31 15:00:03 -07:00 • committed by GitHub
parent fa6f06e56b
commit 1d2679f4f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 6 deletions

View file

@ -332,7 +332,7 @@ def assert_attribution_build(page: Any) -> dict[str, Any]:
Catches the staleness failure: a shipping dist left in the directory handed
to `unsloth studio --frontend <dir>` produces a perfectly healthy Unsloth
serving the WRONG bundle, with no profiling renderer and therefore a React
stage that reads 0.00. `attribution/vite.studiobench.config.ts` defines
stage that reads 0.00. `../attribution/vite.studiobench.config.ts` defines
`__STUDIOBENCH_ATTRIBUTION_BUILD__` for exactly this check.
"""
marker = page.evaluate("globalThis.__STUDIOBENCH_ATTRIBUTION_BUILD__ === true")
@ -341,7 +341,8 @@ def assert_attribution_build(page: Any) -> dict[str, Any]:
"not_the_attribution_build",
"__STUDIOBENCH_ATTRIBUTION_BUILD__ is not defined in the loaded bundle. The "
"directory passed to `unsloth studio --frontend` is serving some other dist, most "
"likely a stale shipping build. Rebuild with attribution/vite.studiobench.config.ts.",
"likely a stale shipping build. Rebuild with "
"tests/studio/studiobench/attribution/vite.studiobench.config.ts.",
)
return {"attribution_build_verified": True}

View file

@ -30,7 +30,7 @@
import { createRequire } from "node:module";
import path from "node:path";
const FRONTEND_ROOT = path.resolve(__dirname, "../studio/frontend");
const FRONTEND_ROOT = path.resolve(__dirname, "../../../../studio/frontend");
// The plugins are resolved from the FRONTEND package, not from this directory,
// and that is not a stylistic preference. Vite bundles a `--config` file with
@ -38,8 +38,8 @@ const FRONTEND_ROOT = path.resolve(__dirname, "../studio/frontend");
// path.dirname(fileName)`) and then loads the bundle under the config file's
// own path: CJS via `module._compile(code, <config path>)`, ESM via a temp file
// in the nearest ancestor `node_modules`, of which this directory has none. So
// Node starts its `node_modules` walk at `attribution/` and climbs to the
// repository root, and NEITHER has a `node_modules` -- only
// Node starts its `node_modules` walk here and climbs to the repository root,
// and NOTHING on that path has a `node_modules` -- only
// `studio/frontend/node_modules` does. Written with plain top-level imports
// this config could not be loaded from any working directory, by any `vite`
// binary: `Cannot find module '@tailwindcss/vite'`, and the same for the React
@ -183,7 +183,7 @@ export default defineConfig({
// Marks the bundle so the harness can prove it is measuring the
// attribution build and not a stale shipping dist left in the
// directory handed to `unsloth studio --frontend`. Read by
// `analysis/bridge_build.py:assert_attribution_build`.
// `../analysis/bridge_build.py:assert_attribution_build`.
//
// This is a BANNER and not a `define`, and the difference is not
// cosmetic. `define` performs identifier SUBSTITUTION in source: it