# Polaris CLI

[![npm version](https://badge.fury.io/js/polaris-cli.svg)](https://www.npmjs.com/package/polaris-cli)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

> ⚡ Command-line interface for managing distributed compute resources in the Polaris network

## Installation

```bash
npm i polaris-cli-tool
```

## Quick Start

```bash
polaris start
```

## Examples

### 1. Register a New Miner

First, prepare your compute resources Excel file:

```excel
id          | resource_type | location    | internal_ip   | ssh                        | open_ports    | hourly_price | ram   | storage_type | storage_capacity
compute1    | CPU          | NYC-RACK-01 | 192.168.1.10  | ssh://user@192.168.1.10:22 | 22,80,443     | 2.0         | 128GB | NVME        | 4TB
compute2    | GPU          | NYC-RACK-02 | 192.168.1.11  | ssh://user@192.168.1.11:22 | 22,80,443,8080| 3.5         | 256GB | NVME        | 8TB
```

Then run the registration:

```bash
$ polaris start

🌟 Select Operation:
> Register Miner

# Enter miner details when prompted
Name: test_miner_01
Location: NYC
Description: High performance cluster

# Drop your Excel file when prompted
📂 Drag and drop your compute resources Excel file here: /path/to/resources.xlsx

# Review and confirm the registration
```

Expected Result:
```bash
✨ Registration Complete

Miner ID: m_1a2b3c4d5e
Compute Resources:
• compute1
• compute2

Important: Save your Miner ID
Your Miner ID is: m_1a2b3c4d5e
You will need this ID to manage your compute resources.
```

### 2. View Miner Details

```bash
$ polaris start

🌟 Select Operation:
> View Miner Compute

🔑 Enter the Miner ID: m_1a2b3c4d5e
```

Expected Result:
```bash
📄 Miner Information
ID            m_1a2b3c4d5e
Name          test_miner_01
Location      NYC
Description   High performance cluster
Created At    2024-01-20 10:30:45
Updated At    2024-01-20 10:30:45

💻 Compute Resources
┌───────────┬──────┬────────────┬─────────┬───────┬─────────┬────────────────────┐
│ ID        │ Type │ Location   │ Price/Hr│ RAM   │ Storage │ Specs              │
├───────────┼──────┼────────────┼─────────┼───────┼─────────┼────────────────────┤
│ compute1  │ CPU  │ NYC-RACK-01│ $2.0    │ 128GB │ 4TB NVME│ 32 CPUs, 3.4GHz   │
│ compute2  │ GPU  │ NYC-RACK-02│ $3.5    │ 256GB │ 8TB NVME│ NVIDIA A100, 80GB  │
└───────────┴──────┴────────────┴─────────┴───────┴─────────┴────────────────────┘
```

### 3. Run Subnet

```bash
$ polaris start

🌟 Select Operation:
> Run Polaris Subnet

🔑 Enter your Miner ID: m_1a2b3c4d5e
```

Expected Result:
```bash
✨ Subnet initialized successfully!

Network Status
● Miner ID: m_1a2b3c4d5e
● Active Nodes: 156
● Total Compute: 1.2 PetaFLOPS
● Network Health: 98.5%
```

## Excel Templates

### 1. CPU Resource Example
```excel
id: compute1
resource_type: CPU
location: NYC-RACK-01
internal_ip: 192.168.1.10
ssh: ssh://user@192.168.1.10:22
open_ports: 22,80,443,3000
hourly_price: 2.0
ram: 128GB
storage_type: NVME
storage_capacity: 4TB
storage_read_speed: 7000MB/s
storage_write_speed: 5000MB/s
cpu_op_modes: 32-bit, 64-bit
cpu_address_sizes: 46 bits physical, 48 bits virtual
cpu_byte_order: Little Endian
total_cpus: 32
online_cpus: 0-31
vendor_id: GenuineIntel
cpu_name: Intel(R) Xeon(R) Platinum 8380 CPU @ 2.30GHz
cpu_family: 6
model: 85
threads_per_core: 2
cores_per_socket: 8
sockets: 2
stepping: 4
cpu_max_mhz: 3400.0
cpu_min_mhz: 1000.0
```

### 2. GPU Resource Example
```excel
id: compute2
resource_type: GPU
location: NYC-RACK-02
internal_ip: 192.168.1.11
ssh: ssh://user@192.168.1.11:22
open_ports: 22,80,443,8080
hourly_price: 3.5
ram: 256GB
storage_type: NVME
storage_capacity: 8TB
storage_read_speed: 7000MB/s
storage_write_speed: 5000MB/s
gpu_name: NVIDIA A100
memory_size: 80GB
cuda_cores: 6912
clock_speed: 1410MHz
power_consumption: 400W
```

[Download Excel Template](https://raw.githubusercontent.com/BANADDA/polaris-cli/main/templates/resource-template.xlsx)

## Common Issues and Solutions

1. **Invalid Excel Format**
```bash
Error: Invalid Excel format
Details: Missing required columns - 'internal_ip', 'ssh'
Solution: Use the provided template and ensure all required fields
```

2. **Network Configuration Error**
```bash
Error: Invalid network configuration
Details: Invalid SSH string format
Solution: Ensure SSH format is ssh://user@ip:port
```

3. **Resource Validation Error**
```bash
Error: Invalid resource specification
Details: CPU resource missing required CPU specifications
Solution: Fill in all required CPU-specific fields for CPU resources
```

## Support

- 📧 Email: mubarakabanadda68@gmail.com
- 🐛 Issues: [GitHub Issues](https://github.com/BANADDA/polaris-cli/issues)
- 📚 Full Documentation: [GitHub Wiki](https://github.com/BANADDA/polaris-cli/wiki)

## License

MIT © [Banadda Mubarak](https://github.com/BANADDA)