ChihHsuan-Yang commited on
Commit
2706e3f
·
verified ·
1 Parent(s): 1414c64

Quiet the validator's uncheckummed-file warning for tool-created cache files

Browse files
Files changed (2) hide show
  1. registry/checksums.sha256 +1 -1
  2. validate.py +39 -4
registry/checksums.sha256 CHANGED
@@ -43,4 +43,4 @@ abcfeff67504846bd853c573170fa2650761ebc6356b241b1149bffa34417c01 docs/reconstru
43
  e263c1473f08b37726726ee8b7c206f6799fa79e4fd1a128ee121ec3197c8ca5 registry/protocols.csv
44
  bc320aef5d23bd813da31bcea4345982fc8ae257802be3ee1446796b367f1b9c registry/release_manifest.json
45
  4c771f1f38b0d2433b61141be08bf61076524b61baf9e6ac1035d8f9fe73bd25 registry/schema.json
46
- e8fcc4ae91b25e640670203d692cc058f246f3bd257eb47afcd939003b745ef2 validate.py
 
43
  e263c1473f08b37726726ee8b7c206f6799fa79e4fd1a128ee121ec3197c8ca5 registry/protocols.csv
44
  bc320aef5d23bd813da31bcea4345982fc8ae257802be3ee1446796b367f1b9c registry/release_manifest.json
45
  4c771f1f38b0d2433b61141be08bf61076524b61baf9e6ac1035d8f9fe73bd25 registry/schema.json
46
+ 3b3f133bc05bb42f3afbf3710de78483b33354fc16c54e75200e35f55f2ceb90 validate.py
validate.py CHANGED
@@ -108,10 +108,34 @@ FORBIDDEN_IN_FEATURES = {
108
  "baseline_final_answer", "baseline_final_passed", "cheapest_successful_protocol",
109
  }
110
 
 
 
 
 
 
 
 
 
111
  FAILS: list[str] = []
112
  WARNS: list[str] = []
113
 
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  def ok(label: str, passed: bool, detail: str = "") -> bool:
116
  print(f" [{'PASS' if passed else 'FAIL'}] {label}" + (f" -- {detail}" if detail else ""))
117
  if not passed:
@@ -369,15 +393,26 @@ def main() -> int:
369
  ok("every checksummed file is present", not absent, f"missing: {absent}")
370
  ok("every checksum matches", not bad, f"mismatched: {bad}")
371
  on_disk = set()
 
372
  for dp, _, fs in os.walk(root):
373
  for fn in fs:
374
  r = os.path.relpath(os.path.join(dp, fn), root)
375
- if r != "registry/checksums.sha256":
376
- on_disk.add(r)
 
 
 
 
 
 
 
377
  extra = sorted(on_disk - set(expected))
378
  if extra:
379
- WARNS.append(f"files present but not checksummed: {extra}")
380
- print(f" [WARN] not in checksums.sha256: {extra}")
 
 
 
381
 
382
  # ---- optional artifacts --------------------------------------------
383
  head("Optional artifacts (absent by design)")
 
108
  "baseline_final_answer", "baseline_final_passed", "cheapest_successful_protocol",
109
  }
110
 
111
+ # Infrastructure that download tools and version control create alongside the
112
+ # release. Not release content, so never expected in checksums.sha256. Matched by
113
+ # PATH COMPONENT, so any depth is covered (e.g. .cache/huggingface/download/*.lock).
114
+ IGNORED_DIR_COMPONENTS = {".cache", ".git", "__pycache__", ".ipynb_checkpoints"}
115
+ IGNORED_BASENAMES = {".gitattributes", ".gitignore", ".DS_Store", ".gitmodules", "Thumbs.db"}
116
+
117
+ MAX_LISTED_OFFENDERS = 10
118
+
119
  FAILS: list[str] = []
120
  WARNS: list[str] = []
121
 
122
 
123
+ def is_infrastructure(rel_path: str) -> bool:
124
+ """True for tool-created files that are not part of the release payload."""
125
+ parts = rel_path.replace(os.sep, "/").split("/")
126
+ if any(part in IGNORED_DIR_COMPONENTS for part in parts[:-1]):
127
+ return True
128
+ return parts[-1] in IGNORED_BASENAMES
129
+
130
+
131
+ def abbreviate(items: "list[str]", limit: int = MAX_LISTED_OFFENDERS) -> str:
132
+ """Render a list without letting it swamp the output."""
133
+ shown = ", ".join(items[:limit])
134
+ if len(items) > limit:
135
+ shown += f", ... and {len(items) - limit} more"
136
+ return shown
137
+
138
+
139
  def ok(label: str, passed: bool, detail: str = "") -> bool:
140
  print(f" [{'PASS' if passed else 'FAIL'}] {label}" + (f" -- {detail}" if detail else ""))
141
  if not passed:
 
393
  ok("every checksummed file is present", not absent, f"missing: {absent}")
394
  ok("every checksum matches", not bad, f"mismatched: {bad}")
395
  on_disk = set()
396
+ skipped_infra = 0
397
  for dp, _, fs in os.walk(root):
398
  for fn in fs:
399
  r = os.path.relpath(os.path.join(dp, fn), root)
400
+ if r == "registry/checksums.sha256":
401
+ continue
402
+ if is_infrastructure(r):
403
+ skipped_infra += 1
404
+ continue
405
+ on_disk.add(r)
406
+ if skipped_infra:
407
+ print(f" ({skipped_infra} tool-created file(s) ignored: download cache, "
408
+ f"version-control and OS metadata)")
409
  extra = sorted(on_disk - set(expected))
410
  if extra:
411
+ # An unexpected extra file is not corruption, so this stays a warning.
412
+ WARNS.append(f"{len(extra)} file(s) present but not checksummed: "
413
+ f"{abbreviate(extra)}")
414
+ print(f" [WARN] {len(extra)} file(s) not in checksums.sha256: "
415
+ f"{abbreviate(extra)}")
416
 
417
  # ---- optional artifacts --------------------------------------------
418
  head("Optional artifacts (absent by design)")