A lightweight MLOps SDK for experiment tracking and model registry
Project description
SimpleML SDK
A lightweight Python SDK for the SimpleML MLOps platform. Track experiments, log metrics, manage artifacts, and register models with ease.
Installation
pip install simpleml
Quick Start
Auto-configuration with CloudFormation Stack
import simpleml
# Auto-configure using your deployed stack
simpleml.configure(stack_name="your-simpleml-stack")
# Start tracking
experiment = simpleml.get_or_create_experiment("my-experiment")
run = experiment.start_run()
# Log metrics
run.log_metrics({
"accuracy": 0.95,
"loss": 0.05
})
# Log hyperparameters
run.log_params({
"learning_rate": 0.001,
"batch_size": 32,
"epochs": 100
})
# Upload artifacts
run.upload_artifact("model.pkl", artifact_type="model")
# Complete the run
run.complete()
Manual Configuration
import simpleml
# Manual configuration
simpleml.configure(
api_endpoint="https://your-api.execute-api.region.amazonaws.com/Prod",
api_key="sk_your_api_key_here"
)
Features
- Experiment Tracking: Organize your ML experiments
- Metrics Logging: Track training and validation metrics over time
- Artifact Management: Upload and manage model files, plots, and data
- Model Registry: Register and version your models
- Auto-configuration: Automatically detect endpoints from CloudFormation
- Lightweight: Minimal dependencies, fast setup
API Reference
Configuration
simpleml.configure(
stack_name="my-stack", # Auto-detect from stack
region="us-west-2", # AWS region
api_endpoint="https://...", # Manual endpoint
api_key="sk_...", # API key
tenant_id="tenant-123" # Tenant ID (optional)
)
Experiments
# Get or create experiment
experiment = simpleml.get_or_create_experiment(
name="image-classification",
description="CIFAR-10 classification experiment",
tags={"dataset": "cifar10", "model": "resnet"}
)
# Get existing experiment
experiment = simpleml.get_experiment("exp-123")
# List experiments
experiments = simpleml.list_experiments()
Runs
# Start a run
run = experiment.start_run(
name="run-1",
hyperparameters={"lr": 0.001, "batch_size": 32},
tags={"optimizer": "adam"}
)
# Get existing run
run = simpleml.get_run("run-123")
Metrics
# Log metrics (always use batch method)
run.log_metrics({
"train_loss": 0.1,
"val_loss": 0.15,
"accuracy": 0.95
}, step=100)
Artifacts
# Upload file
run.upload_artifact("model.pkl", artifact_type="model")
# Upload with custom name
run.upload_artifact("./plots/confusion_matrix.png",
filename="confusion_matrix.png",
artifact_type="plot")
# List artifacts
artifacts = run.list_artifacts()
# Download artifact
run.download_artifact("artifact-123", "./downloads/model.pkl")
Models
# Register model from run
model = run.register_model(
model_name="cifar10-classifier",
artifacts=["model.pkl", "config.json"],
description="ResNet model for CIFAR-10",
stage="staging"
)
# List models
models = simpleml.list_models()
# Update model stage
simpleml.update_model_stage("cifar10-classifier", "v1", "production")
Context Manager Usage
import simpleml
simpleml.configure(stack_name="my-stack")
with simpleml.start_run("my-experiment") as run:
# Your training code here
for epoch in range(10):
loss = train_epoch()
accuracy = validate()
run.log_metrics({
"loss": loss,
"accuracy": accuracy
}, step=epoch)
# Upload model
run.upload_artifact("model.pkl", artifact_type="model")
# Register model if performance is good
if accuracy > 0.9:
run.register_model("my-model", ["model.pkl"])
Environment Variables
You can also configure using environment variables:
export SIMPLEML_API_ENDPOINT="https://your-api.execute-api.region.amazonaws.com/Prod"
export SIMPLEML_API_KEY="sk_your_api_key_here"
export SIMPLEML_TENANT_ID="tenant-123"
Error Handling
from simpleml.exceptions import SimpleMLError, AuthenticationError, NotFoundError
try:
run = simpleml.get_run("invalid-run-id")
except NotFoundError:
print("Run not found")
except AuthenticationError:
print("Invalid API key")
except SimpleMLError as e:
print(f"SimpleML error: {e}")
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 simplemlplatform-1.0.0.tar.gz.
File metadata
- Download URL: simplemlplatform-1.0.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b6d65a6bebf6ac74761c381536eea68097938a74b51366c5f7e313d2f1a27f4
|
|
| MD5 |
341933d6a3b3c0720ca190dc2219f2e8
|
|
| BLAKE2b-256 |
b0b791164a1faacc85a42cd223f7c8aa6d25cfe9bf8dd47fcebff13517c42264
|
File details
Details for the file simplemlplatform-1.0.0-py3-none-any.whl.
File metadata
- Download URL: simplemlplatform-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad040936e217de1352038840bdd37a62db4e594cf502e97a79fe5f0ac931bf44
|
|
| MD5 |
510cb12d6e0593c278356f200f6fd522
|
|
| BLAKE2b-256 |
8ab37485248643f459b2dd2dea8e9d9903c57f223719053c99eaad51667ead3b
|