File size: 1,685 Bytes
8fa3dd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
62
63
64
from __future__ import annotations

import argparse
from pathlib import Path
import zipfile

EXCLUDE_DIRS = {
    ".git",
    ".cache",
    ".venv",
    "venv",
    "artifacts",
    "checkpoints",
    "runs",
    "wandb",
    "raw_data",
    "processed_data",
    "__pycache__",
    ".ipynb_checkpoints",
}
EXCLUDE_SUFFIXES = {
    ".pt", ".pth", ".ckpt", ".safetensors", ".bin", ".gguf",
    ".db", ".sqlite", ".sqlite3", ".key", ".pem", ".token",
}
EXCLUDE_NAMES = {".env", "kaggle.json", ".netrc"}


def should_include(path: Path, root: Path) -> bool:
    rel = path.relative_to(root)
    if set(rel.parts) & EXCLUDE_DIRS:
        return False
    if path.name in EXCLUDE_NAMES:
        return False
    if path.suffix.lower() in EXCLUDE_SUFFIXES:
        return False
    return path.is_file()


def package(root: Path, out: Path) -> int:
    out.parent.mkdir(parents=True, exist_ok=True)
    count = 0
    with zipfile.ZipFile(out, "w", compression=zipfile.ZIP_DEFLATED) as z:
        for path in sorted(root.rglob("*")):
            if should_include(path, root):
                arcname = root.name + "/" + str(path.relative_to(root))
                z.write(path, arcname)
                count += 1
    return count


def main() -> None:
    parser = argparse.ArgumentParser(description="Create a public-safe Ares Static Space zip.")
    parser.add_argument("--root", default=".")
    parser.add_argument("--out", default="../ares-static-space-public.zip")
    args = parser.parse_args()
    root = Path(args.root).resolve()
    out = Path(args.out).resolve()
    count = package(root, out)
    print(f"Wrote {out} with {count} files")


if __name__ == "__main__":
    main()