File size: 877 Bytes
98bde72
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
"""Download selected pinned artifacts. Does not download weights by default."""
import argparse,json
from pathlib import Path

def main():
    p=argparse.ArgumentParser();p.add_argument('component');p.add_argument('--destination',required=True);p.add_argument('--weights',action='store_true');a=p.parse_args()
    from huggingface_hub import snapshot_download
    registry=json.loads((Path(__file__).resolve().parents[1]/'configs/model_registry.json').read_text())
    x=registry[a.component]
    if not x.get('revision'):raise ValueError('resolve and freeze a revision before downloading this component')
    snapshot_download(repo_id=x['repo_id'],repo_type=x.get('repo_type','model'),revision=x['revision'],local_dir=a.destination,
       allow_patterns=None if a.weights else ['*.py','*.json','*.yaml','*.yml','*.txt','*.md','*.toml','*.sh'])
if __name__=='__main__':main()