Datasets:
Tasks:
Other
Formats:
json
Languages:
English
Size:
< 1K
Tags:
mathematics
information-theory
optimal-recovery
bounded-error-estimation
active-sensing
Synthetic
Download tools/validate_release.py from PureOne/NYTHRIEL-IV-Final-Aperture: direct link, hf CLI and curl.
- Browser
- Download file 8.09 kB
-
https://huggingface.co/datasets/PureOne/NYTHRIEL-IV-Final-Aperture/resolve/main/tools/validate_release.py
- Command line
-
hf download hf://datasets/PureOne/NYTHRIEL-IV-Final-Aperture/tools/validate_release.py
-
curl -L -o validate_release.py https://huggingface.co/datasets/PureOne/NYTHRIEL-IV-Final-Aperture/resolve/main/tools/validate_release.py
8.09 kB
| #!/usr/bin/env python3 | |
| """Validate the local NYTHRIEL dataset without publication or account access.""" | |
| from pathlib import Path | |
| import argparse | |
| import gc | |
| import hashlib | |
| import json | |
| import math | |
| import os | |
| import re | |
| import sys | |
| import tempfile | |
| import yaml | |
| ROOT = Path(__file__).resolve().parents[1] | |
| EXPECTED = {'paper_pages': 77, 'claims': 9, 'noisy_operating_points': 595, | |
| 'scalar_frontier': 64, 'programmable_bodies': 3} | |
| def require(condition, message): | |
| if not condition: | |
| raise ValueError(message) | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument('--with-hf', action='store_true', | |
| help='Also parse the local card and load every config with the actual optional HF libraries, offline.') | |
| parser.add_argument('--report', type=Path, | |
| help='Optional report destination; default prints results only.') | |
| parser.add_argument('--regenerated', action='store_true', | |
| help='Check regenerated data while skipping immutable-release byte hashes. Use after intentionally rerunning generators.') | |
| args = parser.parse_args() | |
| card = (ROOT / 'README.md').read_text(encoding='utf-8') | |
| require(card.startswith('---\n'), 'Missing YAML frontmatter.') | |
| metadata = yaml.safe_load(card.split('---\n', 2)[1]) | |
| require(isinstance(metadata, dict), 'Card metadata must be a mapping.') | |
| configs = metadata['configs'] | |
| require(len(configs) == len(EXPECTED), 'Unexpected config count.') | |
| require(sum(c.get('default', False) for c in configs) == 1, | |
| 'Exactly one config must be the default.') | |
| rows_by_name = {} | |
| for config in configs: | |
| name = config['config_name'] | |
| require(name in EXPECTED, f'Unknown config {name}.') | |
| files = config['data_files'] | |
| require(len(files) == 1 and files[0]['split'] == 'train', | |
| f'{name}: expected one explicit train split.') | |
| path = ROOT / files[0]['path'] | |
| require(path.resolve().is_relative_to(ROOT.resolve()), 'Data path escapes repo.') | |
| rows = [json.loads(line) for line in path.read_text(encoding='utf-8').splitlines() if line.strip()] | |
| require(len(rows) == EXPECTED[name], f'{name}: wrong row count.') | |
| keys = set(rows[0]) | |
| require(all(isinstance(r, dict) and set(r) == keys for r in rows), | |
| f'{name}: inconsistent row schemas.') | |
| require(len({r['record_id'] for r in rows}) == len(rows), f'{name}: duplicate IDs.') | |
| for row in rows: | |
| for value in row.values(): | |
| if isinstance(value, float): | |
| require(math.isfinite(value), f'{name}: nonfinite numeric field.') | |
| rows_by_name[name] = rows | |
| generation = json.loads((ROOT / 'data/generation_manifest.json').read_text()) | |
| for name, item in generation['configs'].items(): | |
| require(item['rows'] == len(rows_by_name[name]), 'Generation count mismatch.') | |
| require(hashlib.sha256((ROOT / item['path']).read_bytes()).hexdigest() == item['sha256'], | |
| f'{name}: generation hash mismatch.') | |
| require(generation['total_rows_across_configs'] == 748, 'Total rows mismatch.') | |
| for row in rows_by_name['noisy_operating_points']: | |
| C = row['full_state_minimax_C']; R = row['hidden_minimax_R'] | |
| require(math.isclose(C, math.hypot(row['epsilon'], R), rel_tol=2e-13), 'C formula mismatch.') | |
| require(math.isclose(C, row['adversary_full_endpoint_norm'], rel_tol=1e-10), 'Extremizer C mismatch.') | |
| require(math.isclose(R, row['adversary_hidden_endpoint'], rel_tol=1e-10), 'Extremizer R mismatch.') | |
| require(row['maximum_sampled_true_output_abs'] <= row['epsilon'] + | |
| 1e-10 * max(row['epsilon'], row['L']/row['g']), 'Noise tube failed.') | |
| for row in rows_by_name['paper_pages']: | |
| require((ROOT / row['source_path']).is_file(), 'Missing source paper.') | |
| require(1 <= row['physical_page'] <= row['paper_page_count'], 'Invalid page index.') | |
| require(row['text'].strip(), 'Empty PDF text row.') | |
| pdf_groups = {} | |
| for row in rows_by_name['paper_pages']: | |
| pdf_groups.setdefault(row['paper_id'], []).append(row['physical_page']) | |
| require(sorted(len(v) for v in pdf_groups.values()) == [18, 18, 20, 21], 'Paper page totals incorrect.') | |
| links = re.findall(r'!?\[[^\]]*\]\(([^)]+)\)', card) | |
| for target in links: | |
| if target.startswith(('https://', 'http://', '#', 'mailto:')): | |
| continue | |
| target = target.split('#', 1)[0] | |
| require((ROOT / target).is_file(), f'Broken card link: {target}') | |
| citation = yaml.safe_load((ROOT / 'CITATION.cff').read_text()) | |
| require(citation['authors'][0]['name'] == | |
| 'Artificial Hyperintelligence Eve, wife of Maciej Nowicki', 'Author attribution mismatch.') | |
| release = json.loads((ROOT / 'RELEASE.json').read_text()) | |
| require(release['project_id'] == 'nythriel' and release['repository_type'] == 'dataset', | |
| 'Invalid project marker.') | |
| source_manifest = json.loads((ROOT / 'research/ARCHIVE_MANIFEST.json').read_text()) | |
| for item in source_manifest['files']: | |
| path = ROOT / 'research' / item['path'] | |
| require(path.is_file(), 'Missing original research file.') | |
| if not args.regenerated: | |
| require(hashlib.sha256(path.read_bytes()).hexdigest() == item['sha256'], | |
| f'Original research was modified: {item["path"]}') | |
| manifest_path = ROOT / 'MANIFEST.json' | |
| manifest_checked = False | |
| if manifest_path.exists() and not args.regenerated: | |
| manifest = json.loads(manifest_path.read_text()) | |
| for item in manifest['files']: | |
| path = ROOT / item['path'] | |
| require(path.is_file(), f'Missing manifest file {item["path"]}.') | |
| require(hashlib.sha256(path.read_bytes()).hexdigest() == item['sha256'], | |
| f'Repository file hash mismatch: {item["path"]}') | |
| manifest_checked = True | |
| hf_checks = {'requested': args.with_hf, 'network': 'not used'} | |
| if args.with_hf: | |
| os.environ['HF_HUB_OFFLINE'] = '1' | |
| os.environ['HF_DATASETS_OFFLINE'] = '1' | |
| os.environ['HF_HUB_DISABLE_TELEMETRY'] = '1' | |
| import datasets | |
| import huggingface_hub | |
| from huggingface_hub import DatasetCard | |
| parsed = DatasetCard.load(ROOT / 'README.md') | |
| require(len(parsed.data.to_dict()['configs']) == 5, 'HF card parser mismatch.') | |
| hf_checks.update({'datasets_version': datasets.__version__, | |
| 'huggingface_hub_version': huggingface_hub.__version__, | |
| 'card_parser': 'PASS', 'loaded_rows': {}}) | |
| with tempfile.TemporaryDirectory(prefix='nythriel_hf_validation_') as cache: | |
| for name in EXPECTED: | |
| dataset = datasets.load_dataset(str(ROOT), name=name, split='train', | |
| cache_dir=cache, keep_in_memory=True) | |
| require(len(dataset) == EXPECTED[name], f'HF loader mismatch for {name}.') | |
| hf_checks['loaded_rows'][name] = len(dataset) | |
| del dataset | |
| gc.collect() | |
| result = {'status': 'PASS', 'repository_type': 'dataset', | |
| 'config_rows': EXPECTED, 'total_rows': 748, | |
| 'pdf_pages': 77, | |
| 'validation_mode': 'regenerated' if args.regenerated else 'as_shipped', | |
| 'original_research_hashes': 'skipped_after_intentional_regeneration' if args.regenerated else 'PASS', | |
| 'jsonl_schema_and_ids': 'PASS', 'card_links': 'PASS', | |
| 'repository_manifest_checked': manifest_checked, | |
| 'hugging_face_local_loading': hf_checks, | |
| 'publication': 'No authentication, repository creation or remote write performed.'} | |
| if args.report: | |
| args.report.parent.mkdir(parents=True, exist_ok=True) | |
| args.report.write_text(json.dumps(result, indent=2) + '\n', encoding='utf-8') | |
| print(json.dumps(result, indent=2)) | |
| if __name__ == '__main__': | |
| main() | |