Spaces:
Runtime error
Runtime error
| #!/usr/bin/env python3 | |
| """ | |
| Upload orbital CLI binary to HuggingFace Hub. | |
| Usage: | |
| # First build the binary: | |
| cd orbital-rust && cargo build --release --bin orbital | |
| # Then upload: | |
| python scripts/upload_orbital_cli.py | |
| """ | |
| import os | |
| import argparse | |
| from pathlib import Path | |
| from huggingface_hub import HfApi, create_repo, upload_file | |
| def main(): | |
| parser = argparse.ArgumentParser(description='Upload orbital CLI to HuggingFace') | |
| parser.add_argument('--repo', default='orbital-ai/orbital-cli', | |
| help='HuggingFace repository') | |
| parser.add_argument('--binary', default=None, | |
| help='Path to orbital binary (auto-detected if not specified)') | |
| args = parser.parse_args() | |
| # Find binary | |
| if args.binary: | |
| binary_path = Path(args.binary) | |
| else: | |
| # Try common locations | |
| candidates = [ | |
| Path.home() / 'kflow.ai.builder/orbital-rust/target/release/orbital', | |
| Path(__file__).parent.parent.parent.parent / 'orbital-rust/target/release/orbital', | |
| Path('/home/osamah/kflow.ai.builder/orbital-rust/target/release/orbital'), | |
| ] | |
| binary_path = None | |
| for candidate in candidates: | |
| if candidate.exists(): | |
| binary_path = candidate | |
| break | |
| if not binary_path: | |
| print("Error: Could not find orbital binary. Build it first:") | |
| print(" cd orbital-rust && cargo build --release --bin orbital") | |
| return 1 | |
| print(f"Binary: {binary_path}") | |
| print(f"Size: {binary_path.stat().st_size / 1024 / 1024:.1f} MB") | |
| # Create repo | |
| api = HfApi() | |
| try: | |
| create_repo(args.repo, repo_type='model', exist_ok=True) | |
| print(f"Repository: https://huggingface.co/{args.repo}") | |
| except Exception as e: | |
| print(f"Note: {e}") | |
| # Upload binary | |
| print(f"\nUploading to {args.repo}...") | |
| upload_file( | |
| path_or_fileobj=str(binary_path), | |
| path_in_repo='orbital-linux-x86_64', | |
| repo_id=args.repo, | |
| commit_message='Upload orbital CLI binary for Linux x86_64' | |
| ) | |
| # Create README | |
| readme = """--- | |
| license: apache-2.0 | |
| tags: | |
| - orbital | |
| - cli | |
| - schema-validation | |
| --- | |
| # Orbital CLI | |
| Binary releases of the Orbital CLI for use in training pipelines. | |
| ## Files | |
| - `orbital-linux-x86_64` - Linux x86_64 binary | |
| ## Usage | |
| ```bash | |
| # Download | |
| wget https://huggingface.co/orbital-ai/orbital-cli/resolve/main/orbital-linux-x86_64 -O orbital | |
| chmod +x orbital | |
| # Validate a schema | |
| ./orbital validate schema.orb | |
| ``` | |
| ## Building from Source | |
| ```bash | |
| cd orbital-rust | |
| cargo build --release --bin orbital | |
| ``` | |
| """ | |
| readme_path = Path('/tmp/orbital-cli-readme.md') | |
| readme_path.write_text(readme) | |
| upload_file( | |
| path_or_fileobj=str(readme_path), | |
| path_in_repo='README.md', | |
| repo_id=args.repo, | |
| commit_message='Add README' | |
| ) | |
| print(f"\nDone! Binary available at:") | |
| print(f" https://huggingface.co/{args.repo}/resolve/main/orbital-linux-x86_64") | |
| return 0 | |
| if __name__ == '__main__': | |
| exit(main()) | |