Python SDK for aphub
Project description
aphub-sdk
Python SDK for aphub - The Docker Hub for AI Agents
Installation
pip install aphub-sdk
Quick Start
Basic Usage
from aphub_sdk import HubClient
from pathlib import Path
# Initialize client
client = HubClient(
base_url="https://hub.aipartnerup.com",
api_key="your-api-key" # Optional, can use token instead
)
# Pull an Agent
result = client.pull(
name="customer-service-agent",
tag="latest",
output_path=Path("./agents")
)
# Push an Agent
result = client.push(
manifest=Path("./agent.yaml"),
tag="latest",
files_path=Path("./agent-files/")
)
# Search Agents
results = client.search(
query="customer service",
framework="aipartnerupflow",
page_size=20
)
# Get Agent details
agent = client.get_agent("customer-service-agent")
# List tags
tags = client.list_tags("customer-service-agent")
Use Cases
1. CI/CD Pipeline Integration
Automatically deploy agents after successful builds:
import os
from aphub_sdk import HubClient
def deploy_in_cicd():
client = HubClient(api_key=os.environ["APHUB_API_KEY"])
result = client.push(
manifest=Path("./dist/agent.yaml"),
tag=os.environ.get("VERSION", "latest"),
files_path=Path("./dist/agent-files"),
)
print(f"Deployed: {result.name}:{result.version}")
2. Custom Web Application
Build custom UIs and backends:
from fastapi import FastAPI
from aphub_sdk import HubClient
app = FastAPI()
client = HubClient()
@app.get("/api/agents")
def list_agents():
result = client.search(query="", page_size=50)
return {"agents": [item.agent.name for item in result.results]}
3. Agent Management Scripts
Batch operations and automation:
client = HubClient(api_key="your-key")
# Bulk operations
for agent_name in ["agent1", "agent2", "agent3"]:
client.pull(agent_name, output_path=Path(f"./backups/{agent_name}"))
4. Agent Testing and Validation
Validate agents before pushing:
def validate_and_push(manifest_path, files_path):
# Your validation logic here
if validate_agent(manifest_path, files_path):
return client.push(manifest_path, files_path=files_path)
else:
raise ValueError("Validation failed")
Advanced Features
Retry Configuration
from aphub_sdk import HubClient
from aphub_sdk.retry import RetryConfig
client = HubClient(
retry_config=RetryConfig(
max_retries=5,
backoff_factor=2.0,
)
)
Token Auto-Refresh
client = HubClient(
access_token="your-access-token",
refresh_token="your-refresh-token",
)
# Tokens automatically refreshed when expired
Progress Tracking
def progress(bytes_sent, total_bytes):
print(f"Progress: {bytes_sent}/{total_bytes}")
client = HubClient(progress_callback=progress)
client.pull("my-agent", output_path=Path("./agents"))
When to Use SDK vs CLI
| Use Case | SDK | CLI |
|---|---|---|
| CI/CD Pipelines | ✅ | ❌ |
| Custom Applications | ✅ | ❌ |
| Scripts/Automation | ✅ | ⚠️ |
| Interactive Use | ⚠️ | ✅ |
| Batch Operations | ✅ | ❌ |
Documentation
- Usage Scenarios - Detailed use cases and examples
- API Reference - Complete API documentation
- Examples - Code examples
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aphub_sdk-0.1.0.tar.gz
(28.3 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
aphub_sdk-0.1.0-py3-none-any.whl
(32.5 kB
view details)
File details
Details for the file aphub_sdk-0.1.0.tar.gz.
File metadata
- Download URL: aphub_sdk-0.1.0.tar.gz
- Upload date:
- Size: 28.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0845c6ac4331d663c129e3766de682df363119a3b6222e64dcd008754e67ee37
|
|
| MD5 |
bd94bf6c5c6fc967b5396def5bdf7023
|
|
| BLAKE2b-256 |
0da0d9f6f5b5960fe090e3677f9b8d6bf42ed197eeece291c09db56e08d4bb75
|
File details
Details for the file aphub_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aphub_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d842b4c9248efc6d5be58623bdc08c015546a5eb8e2378e6f381818b64bbf3d
|
|
| MD5 |
73acb7531af5c1ff3dbe3b5a58805b1b
|
|
| BLAKE2b-256 |
a8eb73aa961e930e4e04b7b625d4429690b88593c66479490aedebca883a53a9
|