Skip to content

Commit 492a1cc

Browse files
committed
fix(ci): track new packages and shipped weights
The repo-root gitignore had data/ (unanchored) which silently matched the new defaultplusplus.data subpackage and excluded it from git. Also drop the legacy pretrained/weights/*.pt / *.pkl rules that pre-dated the 0.4.0 decision to ship trained weights inside the wheel. Stages the previously-ignored files: - defaultplusplus.data (data download + CLI) - pretrained/weights/{encoder,decoder}.pt Updates test_phase0_gate.test_pretrained_weights_are_tracked so the suite enforces the inverted invariant: the weights MUST be tracked or the next wheel build silently breaks.
1 parent 84df265 commit 492a1cc

8 files changed

Lines changed: 549 additions & 13 deletions

File tree

.gitignore

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,23 @@ results/
4646
*.fls
4747
*.synctex.gz
4848

49-
# Pretrained weights (downloaded on first use)
50-
src/defaultplusplus/pretrained/weights/*.pt
51-
src/defaultplusplus/pretrained/weights/*.pkl
49+
# Pretrained weights are tracked under
50+
# defaultplusplus/src/defaultplusplus/pretrained/weights/ — they ship
51+
# with the wheel (~5 MB total). The old "weights are downloaded on
52+
# first use" rules below are intentionally NOT used for the in-tree
53+
# pretrained checkpoints; they remain only in case some research-side
54+
# script writes a separate cache to a project root location.
5255

5356
# Temp staging
5457
.tmp/
55-
.0_DEFault-Previous-Work/
58+
.0_DEFault-Previous-Work/
5659
evaluation/
57-
2_Raw-to-Standardized/
58-
data/
60+
2_Raw-to-Standardized/
61+
# Top-level only — DO NOT use bare ``data/`` here; that pattern would
62+
# also match the installable ``defaultplusplus/src/defaultplusplus/data/``
63+
# subpackage and cause CI checkouts to be missing the data download
64+
# module.
65+
/data/
5966
remaining-tasks.md
6067

6168

defaultplusplus/.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.venv/
22
.pytest_cache/
33
results/
4-
src/defaultplusplus/pretrained/weights/*.pt
5-
src/defaultplusplus/pretrained/weights/*.pkl
4+
# Pretrained weights ARE tracked (they ship in the wheel). If any
5+
# research-side script writes ad-hoc .pkl checkpoints, prefer naming
6+
# them with a clearly-temporary suffix (e.g. ``*.tmp.pkl``) and
7+
# adding that pattern instead.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""Public bench-dataset distribution.
2+
3+
The training data CSVs are too large to ship in the wheel, so the
4+
package downloads them on demand.
5+
6+
from defaultplusplus.data import download_bench
7+
path = download_bench(version="v1") # ~/.cache/defaultplusplus/bench/v1
8+
# or
9+
defaultpp-bench-download # console script
10+
11+
Verifies SHA256 before extraction and short-circuits when an existing
12+
download already matches the expected checksum, so re-running is free.
13+
"""
14+
from .download import (
15+
BENCH_VERSIONS,
16+
BenchVersion,
17+
DatasetNotPublishedError,
18+
DownloadError,
19+
bench_dir,
20+
download_bench,
21+
)
22+
23+
__all__ = [
24+
"BENCH_VERSIONS",
25+
"BenchVersion",
26+
"DatasetNotPublishedError",
27+
"DownloadError",
28+
"bench_dir",
29+
"download_bench",
30+
]
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
"""``defaultpp-bench-download`` console script.
2+
3+
Downloads + verifies + extracts the published DEFault++ benchmark to
4+
the user's cache. Idempotent — re-running on a verified cache is a
5+
no-op.
6+
7+
defaultpp-bench-download # latest version
8+
defaultpp-bench-download --version v1
9+
defaultpp-bench-download --force # bypass cache and re-fetch
10+
defaultpp-bench-download --list # show known versions
11+
12+
Override the source for testing or mirroring:
13+
14+
defaultpp-bench-download --url file:///path/to/bundle.tar.gz \\
15+
--sha256 <expected sha>
16+
"""
17+
from __future__ import annotations
18+
19+
import argparse
20+
import sys
21+
from pathlib import Path
22+
23+
from .download import (
24+
BENCH_VERSIONS,
25+
DEFAULT_VERSION,
26+
DatasetNotPublishedError,
27+
DownloadError,
28+
bench_dir,
29+
download_bench,
30+
)
31+
32+
33+
def _format_versions() -> str:
34+
rows = []
35+
for name, info in BENCH_VERSIONS.items():
36+
status = "PUBLISHED" if info.url else "NOT YET PUBLISHED"
37+
rows.append(f" {name:6s} [{status}] {info.description}")
38+
return "\n".join(rows)
39+
40+
41+
def main(argv: list[str] | None = None) -> int:
42+
p = argparse.ArgumentParser(description=__doc__)
43+
p.add_argument("--version", default=DEFAULT_VERSION,
44+
help=f"bench version (default: {DEFAULT_VERSION})")
45+
p.add_argument("--cache-dir", type=Path, default=None,
46+
help="override the cache root (default: "
47+
"$DEFAULTPP_CACHE_DIR / $XDG_CACHE_HOME / platform default)")
48+
p.add_argument("--force", action="store_true",
49+
help="wipe cached extract and re-download")
50+
p.add_argument("--url", default=None,
51+
help="custom source URL (file:// or http(s)://); requires --sha256")
52+
p.add_argument("--sha256", default=None,
53+
help="expected SHA256 for --url")
54+
p.add_argument("--no-verify", action="store_true",
55+
help="skip per-file MANIFEST verification (faster on known-good cache)")
56+
p.add_argument("--list", action="store_true",
57+
help="print the known bench versions and exit")
58+
args = p.parse_args(argv)
59+
60+
if args.list:
61+
print("Available bench versions:")
62+
print(_format_versions())
63+
return 0
64+
65+
if (args.url is None) ^ (args.sha256 is None):
66+
print("ERROR: --url and --sha256 must be used together",
67+
file=sys.stderr)
68+
return 2
69+
70+
try:
71+
path = download_bench(
72+
version=args.version,
73+
cache_dir=args.cache_dir,
74+
force=args.force,
75+
url_override=args.url,
76+
sha256_override=args.sha256,
77+
verify_manifest=not args.no_verify,
78+
)
79+
except DatasetNotPublishedError as exc:
80+
print(f"ERROR: {exc}", file=sys.stderr)
81+
return 3
82+
except DownloadError as exc:
83+
print(f"ERROR: {exc}", file=sys.stderr)
84+
return 1
85+
86+
print(f"[ok] benchmark {args.version} ready at:")
87+
print(f" {path}")
88+
print()
89+
print(f"Trainer entry point:")
90+
print(f" python defaultplusplus/scripts/train_diagnoser.py \\\\")
91+
print(f" --arch encoder \\\\")
92+
print(f" --csv {path / 'encoder_merged.csv'} \\\\")
93+
print(f" --output encoder.pt")
94+
return 0
95+
96+
97+
if __name__ == "__main__":
98+
raise SystemExit(main())

0 commit comments

Comments
 (0)