Download tools/validate_dataset.py from PureOne/Nhoshiyalun72-Soryuma-Conserved-Task-Memory: direct link, hf CLI and curl.
- Browser
- Download file 3.89 kB
-
https://huggingface.co/datasets/PureOne/Nhoshiyalun72-Soryuma-Conserved-Task-Memory/resolve/main/tools/validate_dataset.py
- Command line
-
hf download hf://datasets/PureOne/Nhoshiyalun72-Soryuma-Conserved-Task-Memory/tools/validate_dataset.py
-
curl -L -o validate_dataset.py https://huggingface.co/datasets/PureOne/Nhoshiyalun72-Soryuma-Conserved-Task-Memory/resolve/main/tools/validate_dataset.py
3.89 kB
| """Validate final-only dataset exports, joins, metrics and optional HF loading. | |
| --with-datasets uses the installed datasets package completely offline. | |
| Reports go outside this sealed repository if --report is supplied. | |
| """ | |
| from pathlib import Path | |
| from fractions import Fraction | |
| import argparse,hashlib,json,math,os | |
| ROOT=Path(__file__).resolve().parents[1] | |
| EXPECTED={'task_edits':324,'acquisitions':108,'independent_checks':36,'autonomous_runs':648,'geometry_recoveries':216} | |
| def validate(with_datasets=False): | |
| views={} | |
| for name,count in EXPECTED.items(): | |
| p=ROOT/'data'/(name+'.jsonl');rows=[json.loads(x) for x in p.read_text(encoding='utf-8').splitlines()] | |
| assert len(rows)==count and len({r['record_id'] for r in rows})==count | |
| assert all(set(r)==set(rows[0]) for r in rows) | |
| views[name]=rows | |
| acq={r['record_id']:r for r in views['acquisitions']} | |
| geom={r['record_id']:r for r in views['geometry_recoveries']} | |
| assert sum(r['source_queries'] for r in acq.values())==318 | |
| assert sum(r['source_details_available'] for r in acq.values())==18 | |
| for r in acq.values(): | |
| assert r['source_queries']==r['constraint_rank'] | |
| assert r['compressed_learned_scalars']==(r['dimension']-r['constraint_rank'])*(r['constraint_rank']+1) | |
| for r in views['task_edits']: | |
| assert r['acquisition_id'] in acq | |
| assert r['oracle_exact'] and r['compiled_decoder_exact'] and r['feasible'] and r['stationary'] | |
| assert r['additional_target_queries']==0 | |
| assert Fraction(r['euclidean_objective_excess_exact'])>=0 | |
| assert sum(Fraction(r['optimal_objective_exact'])>0 for r in views['task_edits'])==319 | |
| assert sum(r['exact_targets'] for r in views['independent_checks'])==180 | |
| assert sum(r['output_error_bounds_verified'] for r in views['independent_checks'])==180 | |
| assert sum(r['source_queries'] for r in geom.values())==864 | |
| runs=views['autonomous_runs'] | |
| assert sum(r['future_steps'] for r in runs)==82944 | |
| assert all(r['geometry_recovery_id'] in geom and r['future_source_updates']==0 and r['future_factors_received']==0 for r in runs) | |
| assert all(r['regret_check_passed'] and r['all_prefix_checks_passed'] for r in runs) | |
| assert max(r['max_prefix_regret'] for r in runs)<8*math.log(10) | |
| total=sum(r['union_square_loss'] for r in runs) | |
| assert math.isclose(total,6152.970380847029,rel_tol=0,abs_tol=1e-8) | |
| report={'row_counts':EXPECTED,'total_rows':sum(EXPECTED.values()),'joins':'passed','research_metric_consistency':'passed', | |
| 'detailed_acquisitions':18,'autonomous_observation_events':82944,'exact_vs_float_scopes_separate':True} | |
| if with_datasets: | |
| os.environ['HF_HUB_OFFLINE']='1';os.environ['HF_DATASETS_OFFLINE']='1' | |
| import datasets | |
| from huggingface_hub import DatasetCard | |
| card=DatasetCard.load(str(ROOT/'README.md')) | |
| assert {c['config_name'] for c in card.data.to_dict()['configs']}==set(EXPECTED) | |
| actual=datasets.get_dataset_config_names(str(ROOT));assert set(actual)==set(EXPECTED) | |
| report['datasets_version']=datasets.__version__;report['hf_loader']={} | |
| for name,count in EXPECTED.items(): | |
| ds=datasets.load_dataset(str(ROOT),name=name,split='train') | |
| assert len(ds)==count | |
| report['hf_loader'][name]={'rows':len(ds),'features':ds.features.to_dict()} | |
| return report | |
| if __name__=='__main__': | |
| ap=argparse.ArgumentParser();ap.add_argument('--with-datasets',action='store_true');ap.add_argument('--report',type=Path) | |
| args=ap.parse_args();report=validate(args.with_datasets) | |
| if args.report: | |
| destination=args.report.resolve() | |
| if destination==ROOT or ROOT in destination.parents:ap.error('--report must be outside the repository folder') | |
| destination.write_text(json.dumps(report,indent=2)+'\n') | |
| print(json.dumps(report,indent=2)) | |