Download download_data.py from bluixe/CV-ICRL: direct link, hf CLI and curl.
- Browser
- Download file 2.5 kB
-
https://huggingface.co/datasets/bluixe/CV-ICRL/resolve/main/download_data.py
- Command line
-
hf download hf://datasets/bluixe/CV-ICRL/download_data.py
-
curl -L -o download_data.py https://huggingface.co/datasets/bluixe/CV-ICRL/resolve/main/download_data.py
2.5 kB
| #!/usr/bin/env python3 | |
| """Download the selected CV-ICRL training histories without deserializing them.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument('--repo-id', default='bluixe/CV-ICRL') | |
| parser.add_argument('--revision', default='camera-ready-v1') | |
| parser.add_argument('--family', choices=['all', 'minigrid', 'procgen'], default='all') | |
| parser.add_argument('--task', action='append', help='Exact task/game name; repeat to select several.') | |
| parser.add_argument('--output-dir', type=Path, default=Path('datasets')) | |
| parser.add_argument('--manifest', type=Path, default=Path(__file__).with_name('manifest.json')) | |
| parser.add_argument('--dry-run', action='store_true') | |
| args = parser.parse_args() | |
| manifest = json.loads(args.manifest.read_text()) | |
| files = [f for f in manifest['files'] if args.family == 'all' or f['family'].lower() == args.family] | |
| if args.task: | |
| unknown = set(args.task) - {f['task'] for f in files} | |
| if unknown: | |
| parser.error('Unknown task(s) for selected family: ' + ', '.join(sorted(unknown))) | |
| files = [f for f in files if f['task'] in args.task] | |
| if not files: | |
| parser.error('No files selected.') | |
| total = sum(f['size_bytes'] for f in files) | |
| print(f'{len(files)} files; {total:,} bytes ({total / 2**30:.2f} GiB)') | |
| for f in files: | |
| print(f"{f['path']} -> {args.output_dir / f['path']}") | |
| if args.dry_run: | |
| return | |
| from huggingface_hub import HfApi, hf_hub_download | |
| info = HfApi().dataset_info(args.repo_id, revision=args.revision, files_metadata=True) | |
| available = {f.rfilename: f.size for f in info.siblings} | |
| missing = [f['path'] for f in files if available.get(f['path']) != f['size_bytes']] | |
| if missing: | |
| raise SystemExit('Selected files are missing or incomplete at this revision: ' + ', '.join(missing)) | |
| print(f'Fixed download revision: {info.sha}') | |
| for f in files: | |
| path = Path(hf_hub_download(repo_id=args.repo_id, repo_type='dataset', revision=info.sha, | |
| filename=f['path'], local_dir=args.output_dir)) | |
| if path.stat().st_size != f['size_bytes']: | |
| raise SystemExit('Downloaded size mismatch: ' + f['path']) | |
| print('Verified byte length: ' + f['path']) | |
| print('All selected files downloaded and byte lengths verified.') | |
| if __name__ == '__main__': | |
| main() | |