axonml-cli 0.6.2

Command-line interface for the Axonml ML framework
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
# axonml-cli

<!-- Logo placeholder -->
<p align="center">
  <img src="https://raw.githubusercontent.com/AutomataNexus/AxonML/main/AxonML-logo.png" alt="AxonML Logo" width="200">
</p>

<p align="center">
  <a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="License: Apache-2.0"></a>
  <a href="https://www.rust-lang.org/"><img src="https://img.shields.io/badge/Rust-1.75+-orange.svg" alt="Rust 1.75+"></a>
  <a href="https://crates.io/crates/axonml-cli"><img src="https://img.shields.io/badge/crates.io-0.6.1-green.svg" alt="Crate Version"></a>
  <a href="https://github.com/AutomataNexus/AxonML"><img src="https://img.shields.io/badge/part_of-AxonML-purple.svg" alt="Part of AxonML"></a>
</p>

---

## Overview

`axonml-cli` is the official command-line interface for the AxonML machine learning framework. The binary is named `axonml` and ships a single `clap`-derived subcommand tree that covers the full ML workflow: project scaffolding, training, evaluation, model conversion, quantization, dataset tooling, GPU management, benchmarking, an embedded terminal UI, optional inference server, optional Weights & Biases integration, dashboard/API-server lifecycle control, and (under the `server-sync` feature) authenticated sync with a running `axonml-server`.

Last updated: 2026-04-16 — version 0.6.1.

---

## Features

- **Project Management** — Create new projects (`new`), initialize existing directories (`init`), and generate Rust training-project scaffolds (`scaffold generate` / `scaffold templates`).

- **Training & Evaluation** — Train from a config file (`train`), resume from a checkpoint (`resume`), evaluate a model (`eval`), run single-input prediction (`predict`), and produce HTML/JSON/text reports (`report`).

- **Model Operations** — Convert between formats (`convert`), export for deployment targets (`export`), inspect architecture (`inspect`), quantize to Q4/Q5/Q8/F16/F32 via `quant convert`, and introspect/benchmark quant levels (`quant info`, `quant benchmark`, `quant list`).

- **Data Management** — Upload, analyze, list, configure, preview, and validate datasets (`data {upload,analyze,list,config,preview,validate}`).

- **Deployment** — Optional REST inference server (`serve`, requires `--features serve`) plus dashboard/server lifecycle (`start`, `stop`, `status`, `logs`).

- **Integrations** — Kaggle dataset search/download (`kaggle`), optional Weights & Biases config (`wandb`, requires `--features wandb`), and pretrained-model hub (`hub`).

- **Terminal UI** — `axonml tui` launches the `axonml-tui` Ratatui interface with an optional model/dataset preloaded.

- **GPU Support** — `gpu list`, `gpu info`, `gpu select`, `gpu bench`, `gpu memory`, `gpu status` over `wgpu`-based device detection.

- **Server Sync** — With `--features server-sync`: `login`, `logout`, and `sync` talk to a live `axonml-server` over HTTPS to mirror training runs, models, and datasets between CLI and web interface.

- **Bundling** — `zip create/extract/list` for model+dataset bundles; `rename model|data` for safe renames; `upload` for pushing a model file into a workspace directory; `load {model,data,both,status,clear}` and `analyze {model,data,both,report}` for workspace-scoped inspection; `bench {model,inference,compare,hardware}` for performance sweeps.

---

## Binary

The crate produces a single binary:

```toml
[[bin]]
name = "axonml"
path = "src/main.rs"
```

There is no `axon` alias target; users who want a shorter name should add a shell alias (`alias axon='axonml'`).

---

## Modules

| Module | Description |
|--------|-------------|
| `cli` | Top-level `clap` derive definitions (the full subcommand tree lives here) |
| `commands` | Per-subcommand `execute` functions under `commands::{new,init,train,resume,eval,predict,convert,export,inspect,report,serve,wandb,upload,data,scaffold,zip,rename,quant,load,analyze,bench,gpu,tui,kaggle,hub,dataset,dashboard,sync}` |
| `config` | Project configuration file parsing (TOML/JSON via `serde`/`toml`) |
| `error` | `CliError` / `CliResult` types |
| `api_client` | HTTP client for server-sync (feature-gated on `server-sync`) |

---

## Installation

Install from crates.io:

```bash
cargo install axonml-cli
```

Or build from source:

```bash
cargo build --release -p axonml-cli
```

The produced binary is `target/release/axonml`.

### Cargo features

Defined in `Cargo.toml`:

- `default = ["wandb", "kaggle", "dataset-api", "hub-download", "server-sync"]`
- `serve` — enables the `serve` subcommand (pulls in `tokio` + `axum`)
- `wandb` — enables the `wandb` subcommand group
- `kaggle` — enables Kaggle HTTP client used by `kaggle search`/`download`
- `dataset-api` — remote dataset listing/downloads
- `hub-download` — HTTP downloads of pretrained weights
- `server-sync` — enables `login`, `logout`, `sync` and the `api_client` module (pulls in `reqwest` + `tokio`)

---

## Command Reference

All commands below are defined in `src/cli.rs` and dispatched in `src/main.rs`.

| Command | Description |
|---------|-------------|
| `new` | Create a new AxonML project |
| `init` | Initialize AxonML in existing directory |
| `train` | Train a model from configuration |
| `resume` | Resume training from checkpoint |
| `eval` | Evaluate model performance |
| `predict` | Make predictions with trained model |
| `convert` | Convert models between formats |
| `export` | Export models for deployment |
| `inspect` | Inspect model architecture |
| `report` | Generate evaluation reports (HTML/JSON/text/all) |
| `serve` | Start inference server (feature: `serve`) |
| `wandb` | W&B integration (feature: `wandb`) |
| `upload` | Upload a model file into a workspace |
| `data` | Dataset management subcommands |
| `scaffold` | Generate Rust training projects |
| `zip` | Create/extract/list model+dataset bundles |
| `rename` | Rename models and datasets |
| `quant` | Quantize, inspect, or benchmark quant levels |
| `load` | Load models/datasets into workspace |
| `analyze` | Comprehensive analysis and reports |
| `bench` | Benchmark models and hardware |
| `gpu` | GPU detection and management |
| `tui` | Launch the terminal user interface |
| `kaggle` | Kaggle dataset integration |
| `hub` | Pretrained model hub |
| `dataset` | Dataset management (NexusConnectBridge) |
| `start` | Start dashboard and API server |
| `stop` | Stop running services |
| `status` | Check service status |
| `logs` | View service logs |
| `login` | Login to AxonML server (feature: `server-sync`) |
| `logout` | Logout from AxonML server (feature: `server-sync`) |
| `sync` | Check/perform sync with server (feature: `server-sync`) |

---

## Usage

### Project Commands

```bash
# Create a new AxonML project
axonml new my-project --template default

# Initialize AxonML in an existing directory
axonml init --name my-project

# Generate a Rust training project scaffold
axonml scaffold generate my-trainer --template training --wandb
```

### Training Commands

```bash
# Train a model from configuration
axonml train --config config.toml --data ./data/train --epochs 50 --device cuda:0

# Resume training from a checkpoint (requires --data)
axonml resume checkpoint.pt --data ./data/train --epochs 20 --lr 0.0001

# Evaluate model performance
axonml eval model.pt ./data/val --metrics accuracy,loss --batch-size 32

# Make predictions
axonml predict model.pt input.json --format json --top-k 5
```

### Model Commands

```bash
# Inspect model architecture
axonml inspect model.pt --detailed --show-params 5

# Convert model formats (ferrite / onnx / safetensors)
axonml convert model.pt model.onnx --to onnx --optimize

# Export for deployment
axonml export model.pt ./deploy --format onnx --target cuda --quantize --precision fp16

# Quantize model (Q4_0, Q4_1, Q5_0, Q5_1, Q8_0, F16, F32)
axonml quant convert model.pt --target Q8_0 --output model_q8.axon

# Inspect or benchmark quant levels
axonml quant info model_q8.axon --detailed
axonml quant benchmark model.pt --iterations 10 --types Q4_0,Q8_0
axonml quant list

# Generate evaluation report
axonml report model.pt --data ./test --format html --confusion-matrix --loss-curves
```

### Data Commands

```bash
# Analyze a dataset
axonml data analyze ./data --detailed --recommend

# Upload and configure dataset
axonml data upload ./images --data-type image --task classification --split 0.8,0.1,0.1

# Validate dataset structure
axonml data validate ./data --check-balance --check-missing

# Preview dataset samples
axonml data preview ./data --num-samples 10 --random

# Generate preprocessing config
axonml data config ./data --output data_config.toml
```

### Workspace Commands

```bash
# Load model into workspace
axonml load model model.pt --name my-model

# Load dataset into workspace
axonml load data ./dataset --data-type tabular

# Load both at once
axonml load both --model model.pt --data ./dataset

# Workspace status / clear
axonml load status
axonml load clear

# Analyze loaded model/dataset
axonml analyze model --detailed --output report.json --format json
axonml analyze data --detailed --max-samples 10000
axonml analyze both --output compat.json

# Generate comprehensive report
axonml analyze report --format html --visualize --output analysis_report.html
```

### Benchmarking

```bash
# Benchmark model performance
axonml bench model model.pt --iterations 100 --batch-size 1 --device cuda:0

# Benchmark at different batch sizes
axonml bench inference model.pt --batch-sizes 1,2,4,8,16,32 --iterations 50

# Compare multiple models
axonml bench compare "model1.pt,model2.pt,model3.pt" --iterations 50

# Benchmark hardware capabilities
axonml bench hardware --iterations 10
```

### GPU Management

```bash
axonml gpu list
axonml gpu info
axonml gpu select cuda:0 --persistent
axonml gpu bench --all --iterations 10
axonml gpu memory
axonml gpu status
```

### Hub & Kaggle Integration

```bash
# Pretrained model hub
axonml hub list
axonml hub info resnet50
axonml hub download resnet50 --force
axonml hub cached
axonml hub clear resnet50        # clear one
axonml hub clear                 # clear all

# Kaggle
axonml kaggle login --username USER --key API_KEY   # credentials saved to ~/.kaggle/kaggle.json with 0600 perms; key is NOT echoed back
axonml kaggle status
axonml kaggle search "image classification" --limit 20
axonml kaggle download username/dataset-name --output ./data
axonml kaggle list
```

Note: `kaggle login` writes credentials to `~/.kaggle/kaggle.json` with Unix mode `0600` and deliberately does not echo the API key (or username) back to stdout to keep it out of shell history / CI logs. Run `axonml kaggle status` after login to confirm.

### Dataset (NexusConnectBridge)

```bash
axonml dataset list --source kaggle
axonml dataset info mnist
axonml dataset search "language model" --source all --limit 20
axonml dataset download mnist --output ./data
axonml dataset sources
```

### Server Sync (CLI <-> Webapp, feature `server-sync`)

```bash
# Login to AxonML server (defaults to http://localhost:3021)
axonml login
axonml login --server http://myserver:3021 --username me

# Check sync status or force re-sync
axonml sync --status
axonml sync --force

# Logout and clear stored credentials
axonml logout
```

### Dashboard & Server

```bash
# Start dashboard and API server (default: API on 3000, dashboard on 8080)
axonml start --port 3000 --dashboard-port 8080

# Start only the API server, in foreground
axonml start --server --foreground

# Check service status
axonml status --detailed --format json

# View logs
axonml logs --follow --lines 100 --level info

# Stop services (SIGTERM; use --force for SIGKILL)
axonml stop
axonml stop --server --force
```

### Bundles, rename, upload, TUI

```bash
# Create / extract / list bundles
axonml zip create --output bundle.axonzip --model model.pt --data ./data --include-config
axonml zip extract bundle.axonzip --output ./extracted --verbose
axonml zip list bundle.axonzip --detailed

# Rename
axonml rename model model.pt new_model.pt --force
axonml rename data ./dataset new_name --force

# Upload a model file into a workspace directory
axonml upload ./model.pt --name my-model --version latest --output ./models --inspect

# Launch TUI
axonml tui --model model.pt --data ./dataset
```

### Weights & Biases (feature `wandb`)

```bash
axonml wandb login
axonml wandb status
axonml wandb config --api-key ... --entity my-team --project my-proj --log-frequency 50 --log-checkpoints true
axonml wandb enable
axonml wandb disable
axonml wandb logout
```

### Inference Server (feature `serve`)

```bash
axonml serve model.pt --host 127.0.0.1 --port 8080 --workers 4 --batch --max-batch-size 32 --timeout 30000
```

---

## Configuration

The CLI uses `axonml.toml` for project configuration. Example:

```toml
[project]
name = "my-ml-project"
version = "0.1.0"
description = "My machine learning project"

[training]
epochs = 50
batch_size = 32
learning_rate = 0.001
device = "cuda:0"
checkpoint_frequency = 1
output_dir = "./output"
num_workers = 4

[training.optimizer]
name = "adam"
weight_decay = 0.0001
beta1 = 0.9
beta2 = 0.999

[training.scheduler]
name = "cosine"
t_max = 50
eta_min = 0.00001
warmup_epochs = 5

[model]
architecture = "resnet18"
num_classes = 10
dropout = 0.1

[data]
train_path = "./data/train"
val_path = "./data/val"
val_split = 0.1
augmentation = true
shuffle = true
normalize = true
```

---

## Global Options

```bash
# Enable verbose output (global flag)
axonml --verbose <command>

# Suppress all output except errors (global flag)
axonml --quiet <command>
```

---

## Tests

```bash
# Unit tests
cargo test -p axonml-cli

# Integration tests (uses assert_cmd / predicates)
cargo test -p axonml-cli --test cli_integration_test
```

---

## License

Licensed under either of:

- MIT License
- Apache License, Version 2.0

at your option.