Skip to main content

Keys & Caches CLI - Accelerate your Python functions with cloud GPUs

Project description

Keys & Caches

Keys & Caches Banner

A Python library for experiment tracking and machine learning workflow management.


What is Keys & Caches?

Keys & Caches is a Python library that provides experiment tracking and workflow management for machine learning projects. With a simple API, you can:

  • 📊 Track experiments — Automatically log metrics and hyperparameters
  • 🌐 Cloud dashboard — Real-time visualization of your experiments
  • 🏷️ Organize projects — Group related experiments together
  • 🎯 Zero-overhead when disabled — Tracking only activates when initialized

Installation

pip install kandc

Quick Start

import kandc
import torch
import torch.nn as nn

class SimpleNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.layers = nn.Sequential(
            nn.Linear(784, 128),
            nn.ReLU(),
            nn.Linear(128, 10),
        )

    def forward(self, x):
        return self.layers(x)

def main():
    # Initialize experiment tracking
    kandc.init(
        project="my-project",
        name="experiment-1",
        config={"batch_size": 32, "learning_rate": 0.01}
    )

    # Your training/inference code
    model = SimpleNet()
    data = torch.randn(32, 784)
    output = model(data)
    loss = output.mean()

    # Log metrics
    kandc.log({"loss": loss.item(), "accuracy": 0.85})

    # Finish the run
    kandc.finish()

if __name__ == "__main__":
    main()

Key Features

🎯 Simple Initialization

kandc.init(
    project="my-ml-project",
    name="experiment-1",
    config={
        "learning_rate": 0.001,
        "batch_size": 32,
        "model": "resnet18",
    }
)

📊 Metrics Logging

# Log single or multiple metrics
kandc.log({"loss": 0.25, "accuracy": 0.92})

# Log with step numbers for training loops
for epoch in range(100):
    loss = train_epoch()
    kandc.log({"epoch_loss": loss}, step=epoch)

🌐 Multiple Modes

# Online mode (default) - full cloud experience
kandc.init(project="my-project")

# Offline mode - local development
kandc.init(project="my-project", mode="offline")

# Disabled mode - zero overhead
kandc.init(project="my-project", mode="disabled")

🔮 Inference Tracking

import kandc
import torch
import torch.nn as nn

class SimpleNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.layers = nn.Sequential(
            nn.Linear(784, 128),
            nn.ReLU(),
            nn.Linear(128, 10)
        )
    
    def forward(self, x):
        return self.layers(x)

def run_inference():
    # Initialize inference tracking
    kandc.init(
        project="inference-demo",
        name="simple-inference",
        config={"batch_size": 32}
    )
    
    # Create model and wrap with profiler
    model = SimpleNet()
    model = kandc.capture_model_instance(model, model_name="SimpleNet")
    model.eval()
    
    # Run inference
    data = torch.randn(32, 784)
    with torch.no_grad():
        predictions = model(data)
        confidence = torch.softmax(predictions, dim=1).max(dim=1)[0].mean()
    
    # Log results
    kandc.log({
        "avg_confidence": confidence.item(),
        "batch_size": 32
    })
    
    kandc.finish()

if __name__ == "__main__":
    run_inference()

Examples

See the examples/ directory for detailed examples:

  • complete_example.py - Simple getting started example
  • offline_example.py - Offline mode usage

API Reference

Core Functions

  • kandc.init() - Initialize a new run with configuration
  • kandc.finish() - Finish the current run and save all data
  • kandc.log() - Log metrics to the current run
  • kandc.get_current_run() - Get the active run object
  • kandc.is_initialized() - Check if kandc is initialized

Run Modes

  • "online" - Default mode, full cloud functionality
  • "offline" - Save everything locally, no server sync
  • "disabled" - No-op mode, zero overhead

🎓 Students & Educators

Email us at founders@herdora.com for support and collaboration opportunities!


📦 Publishing to PyPI

🚀 Publish Stable Release

  1. Bump the version in pyproject.toml (e.g., 0.0.15).

  2. Run the following commands:

    rm -rf dist build *.egg-info
    python -m pip install --upgrade build twine
    python -m build
    export TWINE_USERNAME=__token__
    twine upload dist/*
    

🧪 Publish Dev Release

  1. Bump the dev version in pyproject.dev.toml (e.g., 0.0.15.dev1).

  2. Run the following commands:

    rm -rf dist build *.egg-info
    cp pyproject.dev.toml pyproject.toml
    python -m pip install --upgrade build twine
    python -m build
    export TWINE_USERNAME=__token__
    twine upload dist/*
    git checkout -- pyproject.toml   # Restore the original pyproject.toml
    

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

kandc-0.0.25.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

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

kandc-0.0.25-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

Details for the file kandc-0.0.25.tar.gz.

File metadata

  • Download URL: kandc-0.0.25.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for kandc-0.0.25.tar.gz
Algorithm Hash digest
SHA256 e5901a1e7f596378e1569c3ae7dbb56156511dc90aa08b45b4d45f6a33b85b0c
MD5 1c3194f37cf769a917a3f56d13aa2240
BLAKE2b-256 c0e756b3b5f8d8c143e2c79179382e5aa2aa4306e2154c49fb26c07e232f565d

See more details on using hashes here.

File details

Details for the file kandc-0.0.25-py3-none-any.whl.

File metadata

  • Download URL: kandc-0.0.25-py3-none-any.whl
  • Upload date:
  • Size: 33.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for kandc-0.0.25-py3-none-any.whl
Algorithm Hash digest
SHA256 b111656b1c1e0919d734adec63a501b2e026f79da82459e17b301a3753a1bcff
MD5 806612e54d4dc65a8cad77caa0aa3037
BLAKE2b-256 94f1d8f121fb80373fc00c96b9e072e50937b0a05437060cf7d499a83db9ea15

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