Spaces:
Running
Running
File size: 1,604 Bytes
5221c8c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #!/usr/bin/env python3
"""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()
|