Metadata-Version: 2.5
Name: datahub-cli
Version: 0.2.1
Summary: Local data catalog and hardware-aware model discovery
Project-URL: Homepage, https://github.com/tyler-ungerman/data-hub
Project-URL: Repository, https://github.com/tyler-ungerman/data-hub
Project-URL: Issues, https://github.com/tyler-ungerman/data-hub/issues
Author: Tyler Ungerman
License-Expression: MIT
License-File: LICENSE
Keywords: catalog,datasets,hugging-face,models,ollama,tui
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Requires-Dist: huggingface-hub>=0.25.0
Requires-Dist: rich>=13.3.3
Requires-Dist: textual>=0.80.0
Requires-Dist: tqdm>=4.42.1
Provides-Extra: all
Requires-Dist: duckdb>=1.1.0; extra == 'all'
Requires-Dist: kaggle>=1.6.0; extra == 'all'
Requires-Dist: onnxruntime>=1.18.0; extra == 'all'
Requires-Dist: pyarrow>=15.0.0; extra == 'all'
Requires-Dist: zstandard>=0.22; extra == 'all'
Provides-Extra: duckdb
Requires-Dist: duckdb>=1.1.0; extra == 'duckdb'
Provides-Extra: kaggle
Requires-Dist: kaggle>=1.6.0; extra == 'kaggle'
Provides-Extra: onnx
Requires-Dist: onnxruntime>=1.18.0; extra == 'onnx'
Provides-Extra: parquet
Requires-Dist: pyarrow>=15.0.0; extra == 'parquet'
Provides-Extra: zstandard
Requires-Dist: zstandard>=0.22; extra == 'zstandard'
Description-Content-Type: text/markdown

# DataHub CLI

DataHub is a terminal tool for finding models and datasets, estimating which models fit your hardware, and tracking local data. It indexes local files in SQLite, caches schemas, and can find project references to catalog items.

## Install

Install DataHub CLI from PyPI. Use `dhub` if Acryl Data’s `acryl-datahub` package already provides a `datahub` command on your PATH.

```sh
uv tool install datahub-cli
uvx datahub-cli
pip install datahub-cli
```

DataHub requires Python 3.11 or newer. `uv tool install` makes both `dhub` and `datahub` available from any terminal without activating an environment.

Optional extras include `parquet` and `onnx` for schema inspection, `kaggle` for Kaggle transfers, `duckdb` for SQL and Parquet previews, and `zstandard` for compressed archives. Install several with `uv tool install 'datahub-cli[duckdb,zstandard]'`, or use `datahub-cli[all]`.

## Quickstart

```sh
datahub init
datahub
datahub sm
datahub sm "qwen" --source ollama --fits -n 10
datahub sd --use-case finance -n 5
datahub scan
datahub ls
datahub info category/dataset-name --json
```

Use an ID from `datahub ls` with `datahub info` or `datahub path`. For model estimates on another memory budget, run `datahub --memory 16G --max-context 4096 sm --fits`. Estimates depend on the runtime and architecture. A quantization plan describes possible configurations. A pull downloads the provider's published artifact.

Ollama search uses the public model catalog without credentials. The selected size and pull tag appear in the TUI inspector and JSON results. DataHub estimates Ollama model sizes at Q4 and embeddings at FP16 when the catalog does not report weights or quantization. Ollama downloads need the `ollama` executable and its local service. Ollama manages the weights, and DataHub records a reference. Setting `OLLAMADB_API_KEY` enables an API fallback if the public search fails. Hugging Face can use `HF_TOKEN` or an existing login for gated downloads. Kaggle needs its CLI and credentials.

Use `--one-page` for a JSON page with a `next_cursor`, then pass it to `--cursor` with the same filters. `--sort newest` orders Ollama results by recency.

| Key | Action |
| --- | --- |
| `1`, `2`, `3` | Switch between Models, Datasets, and Local Catalog |
| `/` | Focus the active tab’s search or filter input |
| ↑ / ↓ | Move between results or options in an open dropdown |
| `Tab` / `Shift+Tab` | Move between controls |
| `Enter` in a search field | Search and focus results |
| `Esc` | Close a dialog or return focus to results |
| `m` | Load another page |
| `p` or Enter on a remote result | Open the pull dialog |
| Enter on a local item | Preview a dataset or open the model launch dialog |
| `c`, `v` | Mark a model and compare marked models |
| `x` | Open the seven-tier quantization plan |
| `q` | Quit |

Press Enter on a result to open its pull dialog. Use the arrow keys in the category dropdown and Tab to edit the fields. Enter on a text field submits the pull.

Both the CLI pull commands and the TUI show download and indexing status. Size, speed, and ETA appear when the provider exposes transfer totals. Downloads with unknown totals show activity until the provider reports completion.

## Configuration

DataHub resolves each path from its CLI flag, environment variable, TOML setting, then default.

| Path | Flag | Environment | TOML | Default |
| --- | --- | --- | --- | --- |
| Data and catalog | `--data-root` | `DATA_ROOT` | `data_root` | `~/data` |
| Project scan root | `--projects-root` | `PROJECTS_ROOT` | `projects_root` | Disabled |

The config file lives at `~/.config/datahub/config.toml`, under `$XDG_CONFIG_HOME/datahub` if set, or under `%APPDATA%\datahub` on Windows. Values can use `~` for the home directory.

```sh
datahub init --data-root ~/data --projects-root ~/work --save-config
datahub scan --deps
```

`init` creates the standard directories and database and prints optional shell settings for `DATA_ROOT`, `HF_HOME`, `TORCH_HOME`, and `OLLAMA_MODELS`. Catalog commands also initialize a missing database on first use. Set a project root before running a dependency scan.

### Storage roots, cache adapters, and remotes

Scan configured roots recursively, or register an existing file or folder in place. The managed `datasets/` and `models/` under `data_root` remain the default locations for new downloads. Existing SQLite catalogs migrate on first open.

```toml
data_root = "~/data"
projects_root = "~/work"
dataset_roots = ["/mnt/bulk/datasets", "~/research/data"]
model_roots = ["/mnt/bulk/models"]
archive_root = "/mnt/cold/datahub"

[discovery]
enabled = true
hf_cache = true
ollama = true
lmstudio = true
llamacpp = true
torch = true
kagglehub = true

[remotes.gpu-box]
type = "ssh"
target = "user@ubuntu-box:/mnt/data"

[remotes.r2]
type = "s3"
target = "s3://my-bucket/datahub"
endpoint_url = "https://example.r2.cloudflarestorage.com"

[remotes.modal-vol]
type = "modal"
target = "my-training-volume:/data"
```

`[discovery].enabled` adds cache discovery to `scan`. `dhub discover` explicitly indexes enabled cache adapters without modifying their files. Switch individual adapters off with their boolean options. Hugging Face and Ollama cache locations follow `HF_HOME` and `OLLAMA_MODELS` when set. Missing roots appear as `[offline]` while their cached schemas and metadata remain searchable.

```sh
dhub sd --use-case vision -n 10
dhub sd --min-gb 0.1 --max-gb 4 -n 10
dhub discover
dhub register ./existing-data --id research/examples --type dataset --tags training
dhub ls datasets --tag training
dhub ls --status offline
dhub ls --adapter ollama
dhub unregister research/examples
```

Hugging Face dataset sizes use card metadata, the Dataset Viewer, and Hub metadata. Exact row counts take precedence over size buckets. A `+` marks partial data and an upper size limit excludes unresolved or partial sizes.

### Preview, query, and launch

```sh
dhub peek research/examples --rows 5
dhub peek research/examples --file train.csv --json
dhub query research/examples 'SELECT count(*) FROM data'
dhub run models/example.gguf --dry-run
dhub serve models/example.gguf --ctx-size 4096 --dry-run
```

Preview statistics describe the sampled rows. With DuckDB installed, a local dataset’s preview also accepts a read-only SQL query. `data` refers to the primary file. Other supported files are available by normalized filename stem with numeric suffixes if names collide. Model launch uses a local Ollama, llama.cpp, or MLX-LM executable. For GGUF, the generated context size and GPU offload are estimates.

### Verify, archive, and transfer

```sh
dhub verify research/examples
dhub verify research/examples --update
dhub dedup --json
dhub archive research/examples
dhub restore research/examples
dhub remotes
dhub push research/examples gpu-box --dry-run
dhub pull-remote research/examples gpu-box --destination ./restored-data
```

The first verification records a SHA-256 baseline. Later checks report missing or changed files. Deduplication reports candidates and space savings. An archive verifies its compressed contents and then removes the original files, retaining the indexed schema. Referenced items and third-party caches cannot be archived. Archive compression uses zstd when available and gzip otherwise.

Remote transfers use rsync over SSH, the AWS CLI or a configured `rclone_remote` for S3, or the Modal CLI. A push uploads a content manifest. A pull stages the files and verifies that manifest before putting them at the requested destination.

### MCP clients

`dhub mcp` runs the built-in read-only stdio server. It exposes catalog listing and details, hardware detection, model and dataset search, and dataset previews.

For **Claude Code**, put this in the project’s `.mcp.json`. For **Cursor**, use the same JSON in `.cursor/mcp.json` or `~/.cursor/mcp.json`.

```json
{
  "mcpServers": {
    "datahub": {"command": "dhub", "args": ["mcp"]}
  }
}
```

For **Codex**, add this to `~/.codex/config.toml`.

```toml
[mcp_servers.datahub]
command = "dhub"
args = ["mcp"]
startup_timeout_sec = 10
tool_timeout_sec = 90
```

If the client launches with a different PATH, use the absolute path to the `dhub` executable.

## Python API

```python
from datahub import detect_hardware, evaluate_model, get_dataset_dir, get_model_path

dataset = get_dataset_dir("category/dataset-name")
checkpoint = get_model_path("weights/my-model")
hardware = detect_hardware(memory="16G")
fit = evaluate_model("example-7B", hardware, max_context=4096)
print(fit.quant, fit.total_gb, fit.verdict)
```

The path helpers resolve indexed IDs or unique names and raise `KeyError` if the item is missing or ambiguous. Each accepts a `data_root` override.

## Development

```sh
uv run ruff check
uv run pytest
uv build
```
