File size: 3,114 Bytes
9791706
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/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())