ColabHive Python SDK
Official Python client for ColabHive Builder APIs.
Train machine learning models on distributed GPUs without managing infrastructure.
Installation
pip install colabhive
Quick Start
from colabhive import ColabHive
# Initialize client
client = ColabHive(
api_key="your_api_key_here",
account_id="your_account_id_here"
)
# Upload dataset
dataset = client.datasets.upload(
name="my_training_data",
file="./data.csv"
)
print(f"Dataset uploaded: {dataset.id}")
# Train model
job = client.training.create(
model="xgboost-regression",
dataset_id=dataset.id,
job_name="My First Model"
)
print(f"Training started: {job.id}")
# Wait for completion
job.wait()
if job.status == "completed":
print("Training complete!")
print(f"Metrics: {job.metrics}")
else:
print(f"Training failed: {job.error_message}")
Authentication
Get your API key and account ID from console.colabhive.com.
client = ColabHive(
api_key="colabhive_sk_...",
account_id="0914e1c6-..."
)
Features
Datasets
# Upload
dataset = client.datasets.upload(name="data", file="./train.csv")
# List
datasets = client.datasets.list(limit=10)
# Get
dataset = client.datasets.get("dataset-id")
# Delete
client.datasets.delete("dataset-id")
Training
# Create training job
job = client.training.create(
model="xgboost-regression",
dataset_id="dataset-id",
job_name="Experiment 1",
hyperparameters={
"n_estimators": 100,
"max_depth": 6
}
)
# List jobs
jobs = client.training.list(limit=10, status="running")
# Get job
job = client.training.get("run-id")
# Wait for completion
job.wait(poll_interval=5, timeout=3600, verbose=True)
# Get metrics
metrics = job.metrics
print(metrics)
# Delete job
client.training.delete("run-id")
Models
# List models
models = client.models.list()
# Get model
model = client.models.get("model-id")
# Download model
path = client.models.download("model-id", "./my_model.pkl")
# Delete model
client.models.delete("model-id")
Model Configurations
# List available model configs
configs = client.training.model_configs(category="ml_classical")
for config in configs:
print(config.model_name, config.display_name)
print(config.default_hyperparameters)
Advanced Usage
Context Manager
with ColabHive(api_key="...", account_id="...") as client:
dataset = client.datasets.upload("data", "./train.csv")
job = client.training.create("xgboost-regression", dataset.id)
job.wait()
Custom Base URL
# For production
client = ColabHive(
api_key="...",
account_id="...",
base_url="https://api.colabhive.com"
)
# For local development
client = ColabHive(
api_key="...",
account_id="...",
base_url="http://localhost:8014"
)
Error Handling
from colabhive import ColabHive, ValidationError, NotFoundError, APIError
client = ColabHive(api_key="...", account_id="...")
try:
dataset = client.datasets.upload("data", "./nonexistent.csv")
except ValidationError as e:
print(f"Invalid request: {e.message}")
except NotFoundError as e:
print(f"Not found: {e.message}")
except APIError as e:
print(f"API error: {e.message} (status: {e.status_code})")
Requirements
- Python 3.8+
- httpx >= 0.24.0
- pydantic >= 2.0.0
Documentation
Support
- Discord: discord.gg/colabhive
- Email: support@colabhive.com
- Issues: GitHub Issues
License
MIT License - see LICENSE file for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
colabhive-0.5.0.tar.gz
(31.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
colabhive-0.5.0-py3-none-any.whl
(35.6 kB
view details)
File details
Details for the file colabhive-0.5.0.tar.gz.
File metadata
- Download URL: colabhive-0.5.0.tar.gz
- Upload date:
- Size: 31.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d8e4fa16ac7384499c083f2697c8ded59772180923ebe5b8782effabf5aa7fd
|
|
| MD5 |
6efbc1d90a38133601e64091b918faef
|
|
| BLAKE2b-256 |
2e8bca67a26c7c67523277b9b275eb523fdce4dfdc954d14d51860238a2ad7a2
|
File details
Details for the file colabhive-0.5.0-py3-none-any.whl.
File metadata
- Download URL: colabhive-0.5.0-py3-none-any.whl
- Upload date:
- Size: 35.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85073202c6338a23c98146460c9eef085562fdbbaab02f850f2c016fcf6969d3
|
|
| MD5 |
77b7e87bab0f2799c5bfc5867ce4252b
|
|
| BLAKE2b-256 |
268c6eb18449f4529cb40a8bcb3036a81bc384ab9ddbdc0cdf405db514545c42
|