Download scripts/package_space.py from ayjays132/PhillNet_Recall: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/ayjays132/PhillNet_Recall/resolve/main/scripts/package_space.py
- Command line
-
hf download hf://ayjays132/PhillNet_Recall/scripts/package_space.py
-
curl -L -o package_space.py https://huggingface.co/ayjays132/PhillNet_Recall/resolve/main/scripts/package_space.py
1.67 kB
| """Package a separate minimal Docker Space; no publication or private data.""" | |
| from pathlib import Path | |
| import argparse,hashlib,json,shutil,zipfile | |
| ROOT=Path(__file__).resolve().parents[1] | |
| def main(): | |
| p=argparse.ArgumentParser();p.add_argument('--wheel',type=Path,required=True);p.add_argument('--directory',type=Path,required=True);p.add_argument('--output',type=Path,required=True);a=p.parse_args() | |
| if a.directory.exists() and any(a.directory.iterdir()):raise ValueError('use an empty new Space directory') | |
| a.directory.mkdir(parents=True,exist_ok=True) | |
| for name in ('README.md','Dockerfile','app.py','index.html','hero.png'):shutil.copyfile(ROOT/'space'/name,a.directory/name) | |
| shutil.copyfile(a.wheel,a.directory/a.wheel.name) | |
| shutil.copyfile(ROOT/'LICENSE',a.directory/'LICENSE') | |
| files=sorted(p for p in a.directory.iterdir() if p.is_file()) | |
| manifest={'schema':'phillnet.release.v1','name':'PhillNet Recall Demo','version':'1.2.0', | |
| 'intended_repository':'ayjays132/PhillNet-Recall-Demo','publication_performed':False, | |
| 'files':[{'path':f.name,'bytes':f.stat().st_size,'sha256':hashlib.sha256(f.read_bytes()).hexdigest()} for f in files]} | |
| (a.directory/'release_manifest.json').write_text(json.dumps(manifest,indent=2)+'\n');files.append(a.directory/'release_manifest.json') | |
| with zipfile.ZipFile(a.output,'w',zipfile.ZIP_DEFLATED,compresslevel=9) as z: | |
| for f in files:z.write(f,'PhillNet-Recall-Space/'+f.name) | |
| print(json.dumps({'archive':str(a.output),'files':len(files),'bytes':a.output.stat().st_size,'sha256':hashlib.sha256(a.output.read_bytes()).hexdigest()},indent=2)) | |
| if __name__=='__main__':main() | |