| |
| """Package demo assets for Google Drive distribution.""" |
|
|
| import argparse |
| import zipfile |
| from pathlib import Path |
|
|
|
|
| REQUIRED_DIRS = [ |
| "data/gradio_human", |
| "data/gradio_animo", |
| "data/gradio_skel", |
| "data/gradio_target_bvh", |
| "data/gradio_z", |
| "data/test", |
| ] |
|
|
|
|
| def repo_root() -> Path: |
| return Path(__file__).resolve().parents[1] |
|
|
|
|
| def parse_args() -> argparse.Namespace: |
| parser = argparse.ArgumentParser(description=__doc__) |
| parser.add_argument( |
| "--output", |
| default="/tmp/sata_demo_assets.zip", |
| help="Output zip path. Default: /tmp/sata_demo_assets.zip", |
| ) |
| return parser.parse_args() |
|
|
|
|
| def main() -> None: |
| args = parse_args() |
| root = repo_root() |
| output = Path(args.output).expanduser().resolve() |
|
|
| missing = [path for path in REQUIRED_DIRS if not (root / path).is_dir()] |
| if missing: |
| raise SystemExit("Missing required asset directories:\n" + "\n".join(f" {path}" for path in missing)) |
|
|
| output.parent.mkdir(parents=True, exist_ok=True) |
| data_dir = root / "data" |
|
|
| with zipfile.ZipFile(output, "w", compression=zipfile.ZIP_DEFLATED) as archive: |
| for path in sorted(data_dir.rglob("*")): |
| if path.is_dir(): |
| continue |
| if "__pycache__" in path.parts: |
| continue |
| if path.suffix == ".pyc" or path.name == ".DS_Store": |
| continue |
| archive.write(path, path.relative_to(root)) |
|
|
| print(output) |
| print(f"{output.stat().st_size / 1024 / 1024:.2f} MB") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|