File size: 1,056 Bytes
15c46ce 1c9b5b6 15c46ce 1c9b5b6 15c46ce | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | """Package the explicit source allowlist, excluding credentials and model weights."""
import argparse
import zipfile
from pathlib import Path
from publish_space import ROOT, source_files
import sys
sys.path.insert(0,str(ROOT))
from settings import OUTPUTS
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--output", default=str(ROOT.parent / "nextgpt-chapter6-submission.zip"))
args = parser.parse_args()
target = Path(args.output).resolve()
with zipfile.ZipFile(target, "w", compression=zipfile.ZIP_DEFLATED) as archive:
for file in source_files():
archive.write(file, "nextgpt-reproduction/" + file.relative_to(ROOT).as_posix())
if OUTPUTS.exists():
for file in OUTPUTS.rglob('*'):
if file.is_file() and file.suffix in ('.json','.txt','.png','.wav','.mp4'):
archive.write(file,'nextgpt-reproduction/submission_results/'+file.relative_to(OUTPUTS).as_posix())
print(f"Created {target} ({target.stat().st_size:,} bytes)")
|