Skip to main content

Python SDK and CLI for QubitHub — developer infrastructure for quantum computing

Project description

qubithub

Python SDK and CLI for QubitHub — developer infrastructure for quantum computing.

pip install qubithub

Quick Start

CLI

# Authenticate
qubithub login

# Execute a circuit
qubithub execute QubitHub/bell-state --watch

# Browse circuits
qubithub circuits list --framework qiskit
qubithub circuits info QubitHub/bell-state

# Clone, edit, push (uses git when available; --no-git for HTTP fallback)
qubithub clone qubithub/bell-state
qubithub circuits push ./bell-state --create

# Manage config
qubithub config set default_shots 4096
qubithub config list

Python SDK

from qubithub import QubitHubClient, RunCreateRequest

client = QubitHubClient(token="your-jwt-token")

# Resolve a circuit by name
circuit = client.resolve_circuit("QubitHub/bell-state")

# Submit an execution run
run = client.create_run(RunCreateRequest(
    circuit_id=str(circuit.id),
    backend_name="qiskit_aer",
    shots=1024,
))
print(f"Run {run.id}: {run.status}")

Async Client

import asyncio
from qubithub import AsyncQubitHubClient, RunCreateRequest

async def main():
    async with AsyncQubitHubClient(token="your-jwt-token") as client:
        circuit = await client.resolve_circuit("QubitHub/bell-state")
        run = await client.create_run(RunCreateRequest(
            circuit_id=str(circuit.id),
            backend_name="qiskit_aer",
            shots=1024,
        ))
        print(f"Run {run.id}: {run.status}")

asyncio.run(main())

Authentication

Three methods, checked in order:

Method Flag / Env Var Header
API key --api-key / QUBITHUB_API_KEY X-API-Key
JWT token --token / QUBITHUB_TOKEN Authorization: Bearer
Stored credentials Auto from ~/.qubithub/config.toml
# Interactive login (stores JWT + refresh token)
qubithub login

# API key (for CI/scripts)
qubithub login --api-key qak_your_key_here

# Direct token
qubithub login --token eyJhbGci...

CLI Commands

qubithub login              Log in (interactive, --api-key, or --token)
qubithub logout             Clear stored credentials
qubithub whoami             Show current user

qubithub clone              Clone a circuit (git when available, HTTP fallback)
qubithub execute            Execute a circuit (flagship command)

qubithub circuits list      List / search circuits
qubithub circuits info      Show circuit details
qubithub circuits fork      Fork a circuit
qubithub circuits push      Push local directory to QubitHub
qubithub circuits init      Scaffold a new circuit from template

qubithub runs list          List your runs
qubithub runs info          Show run details + results
qubithub runs cancel        Cancel a run
qubithub runs stats         Show run statistics

qubithub keys create        Create an API key
qubithub keys list          List API keys
qubithub keys revoke        Revoke an API key

qubithub config set         Set a CLI default
qubithub config get         Get a CLI default
qubithub config list        List all CLI defaults
qubithub config unset       Remove a CLI default

Global options: --base-url, --api-key, --token, --format (rich|json).

Error Handling

The SDK provides a granular exception hierarchy:

from qubithub import (
    QubitHubError,       # Base — catch everything
    APIError,            # Any HTTP 4xx/5xx
    AuthenticationError, # 401
    AuthorizationError,  # 403
    NotFoundError,       # 404
    ConflictError,       # 409
    ValidationError,     # 422
    RateLimitError,      # 429 (includes retry_after)
    ServerError,         # 5xx
    NetworkError,        # Connection/timeout failures
    ConfigurationError,  # Bad local config
)

try:
    circuit = client.resolve_circuit("user/nonexistent")
except NotFoundError:
    print("Circuit not found")
except QubitHubError as e:
    print(f"Error: {e.message}")

Configuration

CLI defaults are stored in ~/.qubithub/config.toml:

[defaults]
default_framework = "pennylane"
default_shots = 4096
default_format = "json"

Requirements

  • Python 3.10+
  • Dependencies: httpx, pydantic, typer, rich, tomli-w

License

Apache 2.0 — see LICENSE.

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

qubithub-0.2.0.tar.gz (79.3 kB view details)

Uploaded Source

Built Distribution

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

qubithub-0.2.0-py3-none-any.whl (47.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for qubithub-0.2.0.tar.gz
Algorithm Hash digest
SHA256 05cd9ef0e069b3f107728c78e649116be33875566f06a9f09d46d4f04debf9ed
MD5 be238eca300547dcc276fc6760b7e20b
BLAKE2b-256 96a732c2409cb802c2ad35f08065fb6ca528641b30e8111e6cfe008e1e1c44bf

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for qubithub-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96c167e0411cb4f0ee1f6bd102c5afec881ee52d49ebd605529d2ebed608877a
MD5 810a2c6c6ad068ed386a46f99201d819
BLAKE2b-256 5dcac3ff39a6dc9afea3dc85f308af0e93456c55f74c11815361b2970cea2bc5

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