Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions scripts/benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ and the pinned
It distinguishes absent and malformed `uv_cache.json`/`uv_build.json` from filesystem read failures
and required core metadata. The source backend embeds its build settings in the installed module, so
changed settings, actual build calls, reinstall work, and required artifact hashes are observable
without timing assumptions. Input artifacts are hash-checked and installed files are replaced
atomically when constructing a malformed-metadata case.
without timing assumptions. The same source archive is also installed through a local flat index to
exercise registry-installed version preferences and the no-preference `--upgrade` path. Input
artifacts are hash-checked and installed files are replaced atomically when constructing a
malformed-metadata case.

```shell
python3 scripts/benchmark/qualify-installed-sidecars.py \
Expand Down
111 changes: 108 additions & 3 deletions scripts/benchmark/qualify-installed-sidecars.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class Fixture:
archive: Path
digest: str
source: bool
registry: bool = False


@dataclass(frozen=True)
Expand All @@ -238,6 +239,7 @@ class FreshnessCase:
flavor: str | None = None
wrong_hash: bool = False
reinstall: bool = False
upgrade: bool = False
outcome: str = "success"
value: str | None = None
installed: int = 0
Expand Down Expand Up @@ -403,6 +405,94 @@ class FreshnessCase:
installed=1,
built=1,
),
FreshnessCase(
"registry-source-fresh", "registry-source", flavor="alpha", value="alpha"
),
FreshnessCase(
"registry-source-valid-changed-settings",
"registry-source",
flavor="beta",
value="alpha",
),
FreshnessCase(
"registry-source-missing-build-settings",
"registry-source",
"build-missing",
flavor="beta",
value="alpha",
),
FreshnessCase(
"registry-source-missing-cache",
"registry-source",
"cache-missing",
flavor="alpha",
value="alpha",
),
FreshnessCase(
"registry-source-malformed-build-settings",
"registry-source",
"build-syntax",
flavor="beta",
value="beta",
installed=1,
built=1,
fallback_value="alpha",
fallback_installed=0,
fallback_built=0,
),
FreshnessCase(
"registry-source-malformed-build-settings-wrong-hash",
"registry-source",
"build-syntax",
flavor="beta",
wrong_hash=True,
outcome="hash-mismatch",
value="alpha",
fallback_outcome="success",
),
FreshnessCase(
"registry-source-malformed-cache",
"registry-source",
"cache-syntax",
flavor="alpha",
value="alpha",
installed=1,
fallback_installed=0,
),
FreshnessCase(
"registry-source-malformed-cache-wrong-hash",
"registry-source",
"cache-syntax",
flavor="alpha",
wrong_hash=True,
outcome="hash-mismatch",
value="alpha",
fallback_outcome="success",
),
FreshnessCase(
"registry-source-malformed-build-upgrade",
"registry-source",
"build-syntax",
flavor="beta",
upgrade=True,
value="beta",
installed=1,
built=1,
fallback_value="alpha",
fallback_installed=0,
fallback_built=0,
),
FreshnessCase(
"registry-source-malformed-build-upgrade-wrong-hash",
"registry-source",
"build-syntax",
flavor="beta",
wrong_hash=True,
upgrade=True,
outcome="hash-mismatch",
value="alpha",
fallback_outcome="success",
),
)


Expand Down Expand Up @@ -462,13 +552,17 @@ def install(
flavor: str | None = None,
wrong_hash: bool = False,
reinstall: bool = False,
upgrade: bool = False,
no_installer_metadata: bool = False,
) -> dict:
digest = "0" * 64 if wrong_hash else self.fixture.digest
requirements = self.root / ("wrong.txt" if wrong_hash else "requirements.txt")
requirements.write_text(
f"{self.fixture.name} @ {self.fixture.archive.as_uri()} --hash=sha256:{digest}\n"
requirement = (
f"{self.fixture.name}=={self.fixture.version}"
if self.fixture.registry
else f"{self.fixture.name} @ {self.fixture.archive.as_uri()}"
)
requirements.write_text(f"{requirement} --hash=sha256:{digest}\n")
arguments = [
"pip",
"install",
Expand All @@ -480,10 +574,14 @@ def install(
"--requirements",
str(requirements),
]
if self.fixture.registry:
arguments.extend(["--find-links", str(self.fixture.archive.parent)])
if flavor is not None:
arguments.extend(["--config-setting", f"flavor={flavor}"])
if reinstall:
arguments.append("--reinstall")
if upgrade:
arguments.append("--upgrade")
if no_installer_metadata:
arguments.append("--no-installer-metadata")
return self.command(*arguments)
Expand Down Expand Up @@ -518,6 +616,8 @@ def initialize(self, *, no_installer_metadata: bool = False) -> dict:
raise AssertionError(
f"Fixture was installed outside its environment: {probe}"
)
if self.fixture.registry and (self.dist_info / "direct_url.json").exists():
raise AssertionError("Registry fixture was recorded as a direct URL")
if self.fixture.source and not no_installer_metadata:
record = (self.dist_info / "RECORD").read_text()
for name in SIDECARS:
Expand Down Expand Up @@ -756,6 +856,7 @@ def freshness(self, case: FreshnessCase) -> None:
flavor=case.flavor,
wrong_hash=case.wrong_hash,
reinstall=case.reinstall,
upgrade=case.upgrade,
)
outcome = case.outcome
value = case.value
Expand Down Expand Up @@ -821,6 +922,7 @@ def freshness(self, case: FreshnessCase) -> None:
"requested_flavor": case.flavor,
"wrong_hash": case.wrong_hash,
"reinstall": case.reinstall,
"upgrade": case.upgrade,
"expected_outcome": outcome,
"expected_value": value,
"expected_installed": installed,
Expand Down Expand Up @@ -869,6 +971,9 @@ def main() -> None:
archive = make_source_archive(fixture_directory, backend)
fixtures = {
"source": Fixture(NAME, VERSION, MODULE, archive, sha256(archive), True),
"registry-source": Fixture(
NAME, VERSION, MODULE, archive, sha256(archive), True, registry=True
),
"wheel": Fixture(
WHEEL_NAME, WHEEL_VERSION, WHEEL_NAME, args.wheel, WHEEL_SHA256, False
),
Expand Down Expand Up @@ -915,7 +1020,7 @@ def main() -> None:
for name, fixture in fixtures.items()
},
"expected_policy": args.expect,
"measurement_scope": "Real installed distributions, diagnostics, source build settings, and artifact hash enforcement; no timing comparison.",
"measurement_scope": "Real installed distributions, diagnostics, direct-URL and registry source build settings, and artifact hash enforcement; no timing comparison.",
"cases": [],
}
try:
Expand Down
Loading