Download scripts/package_release.py from ayjays132/PhillNet_Recall: direct link, hf CLI and curl.
- Browser
- Download file 2.16 kB
-
https://huggingface.co/ayjays132/PhillNet_Recall/resolve/main/scripts/package_release.py
- Command line
-
hf download hf://ayjays132/PhillNet_Recall/scripts/package_release.py
-
curl -L -o package_release.py https://huggingface.co/ayjays132/PhillNet_Recall/resolve/main/scripts/package_release.py
2.16 kB
| """Create an allowlisted source release. Does not publish or include private memory.""" | |
| from pathlib import Path | |
| import argparse,hashlib,json,zipfile | |
| ROOT=Path(__file__).resolve().parents[1] | |
| ROOT_FILES=['CHANGELOG.md','README.md','MODEL_CARD.md','MODEL_CARD_PREVIEW.html','LICENSE','NOTICE.md', | |
| 'config.json','rankers.ugr','model.safetensors','evidence.ugr','evidence.safetensors','evidence.json','sensemap.json','pyproject.toml','requirements.txt','Dockerfile','.dockerignore','.gitignore','.gitattributes'] | |
| DIRECTORIES=['phillnet_recall','native','scripts','tests','examples','docs','assets','reports','provenance','deploy','space','.github'] | |
| IGNORE={'__pycache__','.pytest_cache','build','dist'} | |
| FORBIDDEN=('.sqlite','.sqlite3','.db','.env','.key','.pem','.sqlite3-wal','.sqlite3-shm','.db-wal','.db-shm') | |
| def main(): | |
| p=argparse.ArgumentParser();p.add_argument('--output',default=str(ROOT.parent/'PhillNet-Recall-1.2.0.zip'));a=p.parse_args() | |
| files=[ROOT/n for n in ROOT_FILES] | |
| for d in DIRECTORIES: | |
| for path in (ROOT/d).rglob('*'): | |
| if path.is_file() and path.suffix not in ('.so','.dll','.dylib') and not any(part in IGNORE for part in path.parts) and path.suffix not in ('.pyc','.pyo'): | |
| if path.is_symlink() or path.name.lower().endswith(FORBIDDEN):raise ValueError(f'refusing private or linked file: {path}') | |
| files.append(path) | |
| files=sorted(set(files)) | |
| manifest={'schema':'phillnet.release.v1','name':'PhillNet Recall','version':'1.2.0','intended_repository':'ayjays132/PhillNet-Recall', | |
| 'publication_performed':False,'files':[{'path':str(p.relative_to(ROOT)),'bytes':p.stat().st_size,'sha256':hashlib.sha256(p.read_bytes()).hexdigest()} for p in files]} | |
| (ROOT/'release_manifest.json').write_text(json.dumps(manifest,indent=2)+'\n') | |
| files.append(ROOT/'release_manifest.json') | |
| out=Path(a.output) | |
| with zipfile.ZipFile(out,'w',zipfile.ZIP_DEFLATED,compresslevel=9) as z: | |
| for f in files:z.write(f,arcname='PhillNet-Recall/'+str(f.relative_to(ROOT))) | |
| print(json.dumps({'archive':str(out),'files':len(files),'bytes':out.stat().st_size,'sha256':hashlib.sha256(out.read_bytes()).hexdigest()},indent=2)) | |
| if __name__=='__main__':main() | |