Skip to main content

Python SDK and CLI for the UnitZero / SAMI Dataset Distribution Platform

Project description

UZ CLI (SAMI)

Python SDK and CLI for the UnitZero / SAMI Dataset Distribution Platform. Upload, download, and manage robotics datasets in LeRobot format.

Note: Dataset uploads require platform admin privileges (globalRole: platform_admin). Regular users can browse and download datasets but cannot upload.

Installation

pip install uz-cli

For development:

cd sami-cli
pip install -e ".[dev]"

Quick Start (CLI)

# Login with invite code (simplest)
sami login --code <YOUR-INVITE-CODE>

# Or login via browser
sami login

# Or login with email/password
sami login --password

# List datasets
sami list

# Upload a dataset (requires admin)
sami upload ./my_dataset --name "Robot Arm Demo"

# Download a dataset
sami download <dataset-id> --output ./downloaded

# Show your info
sami whoami

# Logout
sami logout

CLI Reference

Command Description
sami login --code <CODE> Login with invite code
sami login Authenticate via browser or email/password
sami logout Clear saved credentials
sami whoami Show current user info
sami config View/set configuration
sami list List accessible datasets
sami upload <path> Upload a LeRobot dataset
sami download <id> Download a dataset
sami info <id> Show dataset details
sami delete <id> Delete a dataset

Command Options

# Upload with options
sami upload ./dataset \
    --name "My Dataset" \
    --description "Kitchen manipulation tasks" \
    --task-category manipulation \
    --workers 8

# Download with options
sami download abc123 \
    --output ./my_data \
    --workers 8

# List with filters
sami list --status ready --limit 50

# Set custom API URL
sami config --api-url https://api.example.com/api/v1

Environment Variables

For CI/CD pipelines, you can use environment variables instead of sami login:

Variable Description
SAMI_API_URL Override API URL
SAMI_ACCESS_TOKEN Use token directly (skip login)
SAMI_INVITE_CODE Invite code for anonymous join (skip login)
SAMI_EMAIL Email for login
SAMI_PASSWORD Password for login
# Example: CI/CD usage with invite code
export SAMI_INVITE_CODE="your-invite-code"
sami list
sami download abc123

# Or use a token directly
export SAMI_ACCESS_TOKEN="your-jwt-token"
sami list

Python SDK

Using Saved Credentials

After running sami login, use credentials in Python:

from sami_cli import SamiClient

# Use saved credentials from ~/.sami/
client = SamiClient.from_saved_credentials()

# List datasets
datasets = client.list_datasets()
for ds in datasets:
    print(f"{ds.name}: {ds.episode_count} episodes")

Invite Code Authentication

from sami_cli import SamiClient

# Authenticate with invite code
client = SamiClient(invite_code="your-invite-code")

# Download a dataset
client.download_dataset(
    dataset_id="<dataset-id>",
    output_path="./downloaded_dataset",
)

Email/Password Authentication

from sami_cli import SamiClient

# Authenticate with email/password
client = SamiClient(
    email="user@example.com",
    password="your-password",
)

# Upload a LeRobot dataset (admin only)
dataset = client.upload_dataset(
    name="my-dataset-v1",
    path="/path/to/lerobot/dataset",
    description="Kitchen manipulation tasks",
    task_category="manipulation",
)
print(f"Uploaded: {dataset.id}")

API Methods

# Authentication
client.login(email, password)
client.get_current_user()

# Datasets
client.list_datasets(page=1, limit=20, status=None)
client.get_dataset(dataset_id)
client.upload_dataset(name, path, description=None, task_category=None, max_workers=4)
client.download_dataset(dataset_id, output_path, max_workers=4)
client.delete_dataset(dataset_id)

# Sharing
client.assign_dataset(dataset_id, organization_id, permission_level)
client.remove_assignment(dataset_id, assignment_id)

LeRobot Format

Datasets must be in LeRobot format:

my_dataset/
  meta/
    info.json       # Required: episodes, frames, fps, features
    stats.json      # Optional: statistics
    episodes/       # Optional: episode metadata
  data/
    chunk-000/      # Parquet files with episode data
    chunk-001/
  videos/           # Optional: video files
    chunk-000/

The meta/info.json must contain:

  • total_episodes: Number of episodes
  • total_frames: Total frame count
  • fps: Frames per second

LeRobot Integration

Downloaded datasets work directly with LeRobot:

from lerobot.common.datasets.lerobot_dataset import LeRobotDataset

# Load downloaded dataset
dataset = LeRobotDataset("./my_dataset")

# Use in training
for batch in dataset:
    observation = batch["observation.state"]
    action = batch["action"]
    # ... train your model

Dataset Object

@dataclass
class Dataset:
    id: str
    name: str
    description: Optional[str]
    task_category: Optional[str]
    robot_type: Optional[str]
    episode_count: Optional[int]
    total_frames: Optional[int]
    fps: Optional[float]
    file_size_bytes: int
    upload_status: str  # pending, uploading, processing, ready, failed
    created_at: datetime
    organization_name: str
    features: Optional[Dict[str, Any]]
    assignments: List[Dict[str, Any]]

Exceptions

from sami_cli import (
    SamiError,              # Base exception
    AuthenticationError,    # Login failed
    NotFoundError,          # Resource not found
    PermissionDeniedError,  # Access denied
    UploadError,            # Upload failed
    DownloadError,          # Download failed
    ValidationError,        # Invalid dataset format
)

Requirements

  • Python >= 3.9
  • requests >= 2.28.0
  • tqdm >= 4.65.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uz_cli-0.2.0.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uz_cli-0.2.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file uz_cli-0.2.0.tar.gz.

File metadata

  • Download URL: uz_cli-0.2.0.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for uz_cli-0.2.0.tar.gz
Algorithm Hash digest
SHA256 acb8a3e3e68107d79484460926b5ebbdc3d73b31dbacc6e90dff1f87093cf330
MD5 ef82253f672cd96194cb94332dbd11ed
BLAKE2b-256 d653e9dc0b7138e9fc54fcd2bd798593452ea132cfcaa7e0026f0950ce46515b

See more details on using hashes here.

File details

Details for the file uz_cli-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: uz_cli-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for uz_cli-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39537638b28f8a267f75271a8f85ccd96d79d8f614be60ac9d9b9d4d3cfc6e46
MD5 02ab510e06d76e811af061f0a40fa977
BLAKE2b-256 a8b9f92647c2a50329cdde4a336a433a219f20f81b4cc115283f7f92696ef0d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page