Skip to main content

Client SDK for logging photonic simulations to OptixLog with MPI support

Project description

OptixLog SDK

Experiment tracking for photonic simulations with automatic MPI support.

🚀 Quick Start

pip install optixlog
from optixlog import Optixlog

# Create client with your API key
client = Optixlog("your_api_key")

# Get or create a project
project = client.project("my_project")

# Create a run
run = project.run("experiment_1")

# Add configuration
run.add_config({"lr": 0.001, "epochs": 100})

# Log metrics
run.log(step=0, loss=0.5, accuracy=0.9)

# Log matplotlib plots
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [1, 4, 9])
run.log_matplotlib("my_plot", fig)

That's it! View your results at optixlog.com

📚 API Structure

from optixlog import Optixlog

# Initialize client
client = Optixlog(api_key)

# Get project (creates automatically if doesn't exist)
project = client.project("project_name_or_id")

# Create a run
run = project.run("run_name")

# Available methods on run:
run.add_config({"key": "value"})      # Add configuration
run.log(step=0, metric=value)         # Log metrics
run.log_image("key", pil_image)       # Log PIL image
run.log_file("key", "path/to/file")   # Log file
run.log_matplotlib("key", fig)         # Log matplotlib figure
run.log_plot("key", x, y)             # Create and log simple plot
run.log_array_as_image("key", array)  # Log numpy array as heatmap
run.log_histogram("key", data)        # Create and log histogram
run.log_scatter("key", x, y)          # Create and log scatter plot
run.log_batch([...])                  # Log multiple metrics in parallel

🎯 Common Use Cases

Parameter Sweep

from optixlog import Optixlog

client = Optixlog(api_key)

for lr in [0.001, 0.01, 0.1]:
    for batch_size in [16, 32, 64]:
        run = client.project("sweep").run(f"lr={lr}_bs={batch_size}")
        run.add_config({"lr": lr, "batch_size": batch_size})
        
        # Your training code here
        for step in range(100):
            loss = train_step(lr, batch_size)
            run.log(step=step, loss=loss)

Training Loop

client = Optixlog(api_key)
run = client.project("training").run("experiment_v1")

run.add_config({
    "model": "resnet50",
    "optimizer": "adam",
    "lr": 0.001
})

for epoch in range(100):
    train_loss = train_epoch()
    val_loss = validate()
    run.log(step=epoch, train_loss=train_loss, val_loss=val_loss)

Log Matplotlib Plots

import matplotlib.pyplot as plt

run = client.project("analysis").run("plots")

# Simple way
fig, ax = plt.subplots()
ax.plot(x, y)
run.log_matplotlib("my_plot", fig)

# Even simpler - create and log in one call
run.log_plot("loss_curve", steps, losses, title="Training Loss", ylabel="Loss")

Log Field Data (Numpy Arrays)

import numpy as np

run = client.project("simulation").run("field_sweep")

field = np.random.rand(100, 100)
run.log_array_as_image("field", field, cmap='hot', title="E-field intensity")

Context Manager Support

with client.project("experiment").run("run_1") as run:
    run.add_config({"param": 1})
    for step in range(100):
        run.log(step=step, loss=compute_loss())
# Automatically prints completion status

🔧 Installation

From PyPI

pip install optixlog

From Source

git clone https://github.com/yourusername/optixlog-sdk.git
cd optixlog-sdk
pip install -e .

🔑 Setup

  1. Get your API key from optixlog.com
  2. Use directly:
client = Optixlog("your_api_key")
  1. Or set environment variable:
export OPTIX_API_KEY="your_api_key"
import os
client = Optixlog(os.getenv("OPTIX_API_KEY"))

✨ Key Features

  • Fluent API: Chain methods naturally: client.project().run().log()
  • Zero Boilerplate: Log matplotlib plots in one line
  • Auto Project Creation: Projects created automatically if they don't exist
  • Context Managers: Clean with statement support
  • Input Validation: Catches NaN/Inf and invalid data
  • Rich Output: Colored console feedback
  • MPI Support: Automatic detection and rank 0 logging
  • Batch Operations: Fast parallel uploads
  • Return Values: Get URLs and status for everything

🛠️ Requirements

  • Python 3.8+
  • requests
  • pillow
  • rich (optional, for colored output)
  • numpy (optional, for array logging)
  • matplotlib (optional, for plot logging)

🚀 What's New in v0.2.0

  • New fluent API: OptixlogProjectRun structure
  • Simplified interface: All logging methods on Run object
  • Auto project creation: No need to create projects manually
  • Chaining support: client.project("x").run("y").add_config({...})

📝 License

MIT License - see LICENSE file for details


Version: 0.2.0
Made with ⚡ for photonic simulation tracking

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

optixlog-0.3.0.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

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

optixlog-0.3.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file optixlog-0.3.0.tar.gz.

File metadata

  • Download URL: optixlog-0.3.0.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for optixlog-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5bf15903bd900bceb18c8c0f8f3d71d82c6dcfad614be29c52e42e918c63fae0
MD5 f4b74df743daaf38be4dddb65327bbc4
BLAKE2b-256 f392bd65fac4998ae9bed6f32c6883a4e53dfdc96d2dafe280af4c26c0525729

See more details on using hashes here.

File details

Details for the file optixlog-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: optixlog-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for optixlog-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82eca098f86fbf7a29c18d20301cbb459dbb93ac1827ae97e9042da920cf4e51
MD5 3f7a3804555b4f6a98d39978332fd017
BLAKE2b-256 e970df9149be3bdd43c14ecb0d0ae2f624c95304a6986aea337186557edc3a42

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