GUI-Swift-4B / prepare_dependencies.py
dongjintao's picture
Release GUI-Swift-4B: Desktop131 SFT step3368
46f5c24 verified
Raw History Blame Contribute Delete
1.79 kB
"""Fetch pinned public dependencies outside the release repository."""
import argparse
import json
import subprocess
from pathlib import Path
from infer import ROOT, verify_files
def main():
p = argparse.ArgumentParser(description=__doc__)
p.add_argument('--destination', type=Path, required=True,
help='A directory on a disk with at least 10 GB available')
args = p.parse_args()
destination = args.destination.resolve()
if destination == ROOT or ROOT in destination.parents:
p.error('Dependencies must be outside the release repository')
destination.mkdir(parents=True, exist_ok=True)
config = json.loads((ROOT / 'gui_swift_config.json').read_text())
upstream = json.loads((ROOT / 'upstream.json').read_text())
source = destination / 'GUI-Decisions'
if not source.exists():
source.mkdir()
subprocess.run(['git', 'init', str(source)], check=True)
subprocess.run(['git', '-C', str(source), 'remote', 'add', 'origin', upstream['repository']], check=True)
subprocess.run(['git', '-C', str(source), 'fetch', '--depth', '1', 'origin', upstream['revision']], check=True)
subprocess.run(['git', '-C', str(source), 'checkout', '--detach', 'FETCH_HEAD'], check=True)
verify_files(source, upstream['files'])
from huggingface_hub import snapshot_download
base = snapshot_download(repo_id=config['base_model'], revision=config['base_revision'],
allow_patterns=list(config['base_files']),
local_dir=str(destination / 'GUI-Owl-1.5-4B-Instruct'))
verify_files(base, config['base_files'])
print(json.dumps({'base_model': str(base), 'gui_decisions': str(source)}, indent=2))
if __name__ == '__main__':
main()