Datasets:
Download scripts/sync_bucket.py from fatmur/dynamicworld: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/datasets/fatmur/dynamicworld/resolve/main/scripts/sync_bucket.py
- Command line
-
hf download hf://datasets/fatmur/dynamicworld/scripts/sync_bucket.py
-
curl -L -o sync_bucket.py https://huggingface.co/datasets/fatmur/dynamicworld/resolve/main/scripts/sync_bucket.py
1.42 kB
| """Upload or download the Dynamic World raw and processed directories.""" | |
| import argparse | |
| from pathlib import Path | |
| from huggingface_hub import sync_bucket | |
| BUCKET = "hf://buckets/fatmur/dynamicworld" | |
| DATA_DIR = Path(__file__).resolve().parents[1] | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("direction", choices=("upload", "download")) | |
| parser.add_argument("part", choices=("raw", "processed", "all")) | |
| parser.add_argument( | |
| "--data-dir", | |
| type=Path, | |
| default=DATA_DIR, | |
| help="Local parent of raw/ and processed/", | |
| ) | |
| parser.add_argument( | |
| "--include", | |
| action="append", | |
| help="Glob relative to each selected folder (repeatable)", | |
| ) | |
| parser.add_argument( | |
| "--dry-run", action="store_true", help="Print the Hugging Face sync plan" | |
| ) | |
| args = parser.parse_args() | |
| folders = ("raw", "processed") if args.part == "all" else (args.part,) | |
| for folder in folders: | |
| local = str(args.data_dir / folder) | |
| remote = f"{BUCKET}/{folder}" | |
| source, dest = ( | |
| (local, remote) if args.direction == "upload" else (remote, local) | |
| ) | |
| sync_bucket( | |
| source, | |
| dest, | |
| include=args.include, | |
| exclude=["*.partial.*"], | |
| dry_run=args.dry_run, | |
| ) | |
| if __name__ == "__main__": | |
| main() | |