Exemple
pooch 1.9.0: make_registry
Échantillon vérifié pour pypi pooch 1.9.0: make_registry. Le contrat s'est exécuté sur python 3.12 · linux alpine/x64 · docker et a réussi.
sha256:1d8861dbe6460160ca28a6c76e1db5862bb2a686b491aaa674dd406777fd698b
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
python linux 24 · ubuntu · glibc 2.39 x64 python python pip
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962… |
2026-08-30 |
Cas
HOW- Objectif
- verify pooch.make_registry in pkg:pypi/pooch@1.9.0
- Paquets
- Symboles
-
- pooch.make_registry
- Environnement
- python
- Créé
- 2026-08-30T19:21:32Z
Contrat
- make_registry scans a directory and writes a registry text file mapping relative POSIX file paths to their SHA-256 checksums.
- With recursive=True (default), make_registry traverses nested subdirectories and normalizes path separators to forward slashes.
- With recursive=False, make_registry only processes top-level files in the specified directory.
- make_registry handles empty directories by generating an empty registry file.
- The generated registry file can be parsed by Pooch.load_registry to populate dataset filenames and SHA-256 hashes.
Fichiers
- NOTES.md
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
Code source
# pooch make_registry API
This sample pins `pooch` 1.9.0 and verifies `pooch.make_registry` for generating checksum registries of dataset files.
The contract verifies:
- `make_registry` scans a directory and writes a registry file with relative file paths and SHA-256 hashes.
- `recursive=True` (default) traverses nested subdirectories with forward slash path separators.
- `recursive=False` restricts the registry to files directly within the target directory.
- `make_registry` safely creates an empty registry file when targeting an empty directory.
- Generated registry files can be loaded by `Pooch.load_registry` into a pooch instance.
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pooch.make_registry in pkg:pypi/pooch@1.9.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/pooch@1.9.0
Demonstrate these symbols/APIs:
- pooch.make_registry
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:8a6234ec7dd2cc883d529a0b9d0e9b619a0e40ee993d5e421ca73741b3fc711b","contract":["make_registry scans a directory and writes a registry text file mapping relative POSIX file paths to their SHA-256 checksums.","With recursive=True (default), make_registry traverses nested subdirectories and normalizes path separators to forward slashes.","With recursive=False, make_registry only processes top-level files in the specified directory.","make_registry handles empty directories by generating an empty registry file.","The generated registry file can be parsed by Pooch.load_registry to populate dataset filenames and SHA-256 hashes."],"goal":"verify pooch.make_registry in pkg:pypi/pooch@1.9.0","kind":"HOW","packages":["pkg:pypi/pooch@1.9.0"],"schemaVersion":1,"symbols":["pooch.make_registry"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/pooch@1.9.0"],"schemaVersion":1,"subject":"pkg:pypi/pooch@1.9.0","symbols":["pooch.make_registry"],"verifierAdapter":"python@1"}
pooch==1.9.0
platformdirs==4.11.5
packaging==26.3
requests==2.34.2
urllib3==2.7.0
certifi==2026.7.22
charset-normalizer==3.5.1
idna==3.19
{
"schemaVersion": 1,
"goal": "verify pooch.make_registry in pkg:pypi/pooch@1.9.0",
"kind": "HOW",
"packages": [
"pkg:pypi/pooch@1.9.0"
],
"symbols": [
"pooch.make_registry"
]
}
import hashlib
from pathlib import Path
import tempfile
import pooch
from pooch import create, make_registry
# 1. Verify make_registry scans a directory and writes space-separated relative paths and SHA-256 hashes
with tempfile.TemporaryDirectory() as tmpdir:
tmp_path = Path(tmpdir)
data_dir = tmp_path / "data"
data_dir.mkdir()
sub_dir = data_dir / "subdir"
sub_dir.mkdir()
f1 = data_dir / "sample.txt"
f1_content = b"Hello, Pooch registry!"
f1.write_bytes(f1_content)
f1_hash = hashlib.sha256(f1_content).hexdigest()
f2 = sub_dir / "nested.csv"
f2_content = b"col1,col2\n1,2\n"
f2.write_bytes(f2_content)
f2_hash = hashlib.sha256(f2_content).hexdigest()
# Recursive make_registry (default recursive=True)
rec_reg_file = tmp_path / "registry_rec.txt"
make_registry(str(data_dir), str(rec_reg_file), recursive=True)
assert rec_reg_file.is_file(), "Registry file must be created"
lines = [
line.strip()
for line in rec_reg_file.read_text(encoding="utf-8").splitlines()
if line.strip()
]
assert len(lines) == 2, f"Expected 2 lines in recursive registry, got {len(lines)}"
expected_entries = {
"sample.txt": f1_hash,
"subdir/nested.csv": f2_hash,
}
for line in lines:
parts = line.split()
assert len(parts) == 2, f"Invalid registry line format: {line}"
fname, h = parts
assert fname in expected_entries, f"Unexpected file in registry: {fname}"
assert h == expected_entries[fname], f"Hash mismatch for {fname}: expected {expected_entries[fname]}, got {h}"
# 2. Verify make_registry with recursive=False ignores subdirectories
nonrec_reg_file = tmp_path / "registry_nonrec.txt"
make_registry(str(data_dir), str(nonrec_reg_file), recursive=False)
assert nonrec_reg_file.is_file(), "Non-recursive registry file must be created"
nonrec_lines = [
line.strip()
for line in nonrec_reg_file.read_text(encoding="utf-8").splitlines()
if line.strip()
]
assert len(nonrec_lines) == 1, f"Expected 1 line in non-recursive registry, got {len(nonrec_lines)}"
fname, h = nonrec_lines[0].split()
assert fname == "sample.txt"
assert h == f1_hash
# 3. Verify make_registry handles empty directories
empty_dir = tmp_path / "empty"
empty_dir.mkdir()
empty_reg_file = tmp_path / "registry_empty.txt"
make_registry(str(empty_dir), str(empty_reg_file))
assert empty_reg_file.is_file(), "Empty registry file must be created"
assert empty_reg_file.read_text(encoding="utf-8") == "", "Empty directory should produce empty registry"
# 4. Verify generated registry file can be loaded by pooch instance
pup = create(path=tmp_path / "cache", base_url="https://example.com/data/", registry=None)
pup.load_registry(str(rec_reg_file))
assert len(pup.registry) == 2, f"Expected 2 registry entries in Pooch, got {len(pup.registry)}"
assert pup.registry["sample.txt"] == f1_hash
assert pup.registry["subdir/nested.csv"] == f2_hash
print("CONTRACT PASS: pooch.make_registry verified offline")
Seeder d'origine
anonyme