Python SDK for Joblet - A distributed task execution system
Project description
Joblet Python SDK
The official Python SDK for Joblet - a distributed job orchestration system with GPU support.
Installation
pip install joblet-sdk-python
Quick Start
from joblet import JobletClient
# Connect to your Joblet server
with JobletClient(
host="your-joblet-server.com",
port=50051,
ca_cert_path="ca.pem",
client_cert_path="client.pem",
client_key_path="client.key"
) as client:
# Run a simple job
job = client.jobs.run_job(
command="echo",
args=["Hello, Joblet!"],
name="my-first-job"
)
print(f"Job started: {job['job_uuid']}")
Configuration
Create ~/.rnx/rnx-config.yml:
version: "3.0"
nodes:
default:
address: "your-joblet-server:50051" # Required: Joblet service endpoint
nodeId: "node-001" # Optional: unique identifier for this node
cert: |
-----BEGIN CERTIFICATE-----
# Your client certificate
-----END CERTIFICATE-----
key: |
-----BEGIN PRIVATE KEY-----
# Your client private key
-----END PRIVATE KEY-----
ca: |
-----BEGIN CERTIFICATE-----
# Your CA certificate
-----END CERTIFICATE-----
Configuration Fields:
address- Required: Joblet service endpoint (port 50051)- Handles all operations: job execution, workflows, logs, metrics, and resource management
- Historical data is handled internally via IPC
nodeId- Optional: Unique identifier for the nodecert- Required: Client certificate for mTLS authenticationkey- Required: Client private key for mTLS authenticationca- Required: CA certificate for server verification
Note: Joblet runs as a unified Linux systemd service on port 50051. The server handles historical data internally via IPC to the persist subprocess. See the Joblet Installation Guide for server setup.
GPU Support
# Run GPU-accelerated job
job = client.jobs.run_job(
command="nvidia-smi",
name="gpu-job",
gpu_count=1,
gpu_memory_mb=4096,
runtime="python-3.11-ml"
)
What You Can Do
Run Jobs Anywhere
# Run compute-intensive tasks on remote servers
job = client.jobs.run_job(
command="python",
args=["train_model.py"],
max_cpu=800, # 8 cores
max_memory=16384, # 16GB
gpu_count=2
)
Stream Logs in Real-Time
# Get complete logs from any job (running or completed)
for chunk in client.jobs.get_job_logs(job['job_uuid']):
print(chunk.decode('utf-8'), end='', flush=True)
Get Job Metrics
# Get all metrics for a job (server streams everything)
for metric in client.jobs.get_job_metrics(job_uuid):
print(f"CPU: {metric['cpu_usage']:.2f}%")
print(f"Memory: {metric['memory_usage'] / 1e9:.2f} GB")
Build Workflows
# Chain multiple jobs with dependencies
workflow = client.jobs.run_workflow(
workflow="data-pipeline.yml",
yaml_content="""
jobs:
preprocess:
command: python preprocess.py
train:
command: python train.py
depends_on: [preprocess]
evaluate:
command: python evaluate.py
depends_on: [train]
"""
)
Manage Resources
# Create isolated networks and persistent storage
network = client.networks.create_network("ml-net", "10.0.1.0/24")
volume = client.volumes.create_volume("data", "100GB")
# Use in jobs
job = client.jobs.run_job(
command="python",
args=["process_data.py"],
network="ml-net",
volumes=["data:/data"]
)
Monitor System Health
# Get real-time system metrics
for metrics in client.monitoring.stream_system_metrics(interval_seconds=5):
cpu = metrics['cpu']['usage_percent']
memory = metrics['memory']['usage_percent']
print(f"System: CPU {cpu:.1f}%, Memory {memory:.1f}%")
API Reference
Jobs
client.jobs.run_job()- Execute a jobclient.jobs.cancel_job()- Cancel a scheduled jobclient.jobs.stop_job()- Stop a running jobclient.jobs.get_job_status()- Get job statusclient.jobs.get_job_logs()- Smart log streaming (historical + live)client.jobs.stream_live_logs()- Live-only log streamingclient.jobs.get_job_metrics()- Stream all job metricsclient.jobs.run_workflow()- Execute a workflow
Resources
client.networks- Network managementclient.volumes- Storage managementclient.monitoring- System monitoringclient.runtimes- Runtime environments
For complete API documentation, see docs/API_REFERENCE.md
Development
Setup
# Clone and setup
git clone https://github.com/ehsaniara/joblet-sdk-python.git
cd joblet-sdk-python
# Install development dependencies (editable mode)
make dev
# Or manually:
pip install -e .[dev]
pre-commit install
Testing
# Run tests with coverage
make test
# Run linting (exactly what CI runs)
make lint
# IMPORTANT: Test package installation before release (CI-like)
make test-package
Why make test-package is Important
Problem: Editable installs (pip install -e .) can mask packaging issues. Your local tests may pass but CI/production installs may fail.
Solution: Before committing or releasing, run:
make test-package
This command:
- Uninstalls the editable version
- Builds a clean package
- Installs it like CI and end-users will
- Runs all tests against the installed package
- Catches issues like missing
__init__.py, incorrect package structure, etc.
After testing, restore editable install:
pip install -e .[dev]
Other Commands
# Build distribution packages
make build
# Regenerate protobuf files
make proto
# Clean build artifacts
make clean
Examples
See the examples/ directory for more detailed usage examples:
01_basic_usage.py- Simple job execution and management02_advanced_features.py- Resource limits, environment variables, GPU support03_streaming_logs.py- Real-time log streaming04_historical_logs_metrics.py- Query historical logs and metrics05_smart_log_streaming.py- Intelligent log streaming (historical + live)06_long_running_job_demo.py- Long-running job with complete log retrieval
For detailed documentation, see examples/README.md
Related Projects
- Joblet - Main orchestration system (server-side)
- joblet-proto - Protocol Buffer definitions
- rnx - Official CLI tool (included in Joblet repo)
License
MIT License - see LICENSE file for details.
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
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
File details
Details for the file joblet_sdk_python-2.1.1.tar.gz.
File metadata
- Download URL: joblet_sdk_python-2.1.1.tar.gz
- Upload date:
- Size: 59.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33a700415e1f6036ffd03d81331741864256c2202b9344c6cba159483d48180b
|
|
| MD5 |
dfffc6d95ee83a431d387a7d915f1954
|
|
| BLAKE2b-256 |
d172e4926e982f00f995e9896b8ef9f26cbc854ba6e386bcc827a817dca74801
|
Provenance
The following attestation bundles were made for joblet_sdk_python-2.1.1.tar.gz:
Publisher:
release.yml on ehsaniara/joblet-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
joblet_sdk_python-2.1.1.tar.gz -
Subject digest:
33a700415e1f6036ffd03d81331741864256c2202b9344c6cba159483d48180b - Sigstore transparency entry: 621786364
- Sigstore integration time:
-
Permalink:
ehsaniara/joblet-sdk-python@f5d54310c0dee0a63f19e179ef6d718e9a71df0f -
Branch / Tag:
refs/tags/v2.1.1 - Owner: https://github.com/ehsaniara
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f5d54310c0dee0a63f19e179ef6d718e9a71df0f -
Trigger Event:
push
-
Statement type:
File details
Details for the file joblet_sdk_python-2.1.1-py3-none-any.whl.
File metadata
- Download URL: joblet_sdk_python-2.1.1-py3-none-any.whl
- Upload date:
- Size: 44.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83162652e7e67d02ab62cb8d14b069c3c3a65830706fefb7a5d9ee5420781df2
|
|
| MD5 |
4316afd4551f7a0999cae7a4ae6d54a1
|
|
| BLAKE2b-256 |
44a9ba7d2723637cb9ad94f94e74785d039d46915a08a96ce80e05336bdc978c
|
Provenance
The following attestation bundles were made for joblet_sdk_python-2.1.1-py3-none-any.whl:
Publisher:
release.yml on ehsaniara/joblet-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
joblet_sdk_python-2.1.1-py3-none-any.whl -
Subject digest:
83162652e7e67d02ab62cb8d14b069c3c3a65830706fefb7a5d9ee5420781df2 - Sigstore transparency entry: 621786366
- Sigstore integration time:
-
Permalink:
ehsaniara/joblet-sdk-python@f5d54310c0dee0a63f19e179ef6d718e9a71df0f -
Branch / Tag:
refs/tags/v2.1.1 - Owner: https://github.com/ehsaniara
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f5d54310c0dee0a63f19e179ef6d718e9a71df0f -
Trigger Event:
push
-
Statement type: