SDK Troubleshooting
Common issues and solutions when using OptixLog SDK.
Authentication Errors
Error: “Missing OPTIX_API_KEY”
Symptoms:
ValueError: Missing OPTIX_API_KEY. Set it via environment variable or pass api_key parameter.Solutions:
-
Set environment variable:
export OPTIX_API_KEY="proj_your_key_here" -
Pass directly:
client = optixlog.init(api_key="proj_your_key_here", ...) -
Check if set:
import os print(os.getenv("OPTIX_API_KEY")) # Should print your key
Error: “Invalid API Key” (401)
Symptoms:
ValueError: ❌ Invalid API Key. Please check your API key and try again.Solutions:
-
Verify your API key:
- Get a new key from https://optixlog.com
- Check for typos or extra spaces
- Ensure key starts with
proj_
-
Check key format:
api_key = os.getenv("OPTIX_API_KEY") print(f"Key length: {len(api_key)}") # Should be reasonable length print(f"Key starts with 'proj_': {api_key.startswith('proj_')}") -
Test with explicit key:
client = optixlog.init( api_key="proj_YOUR_KEY_HERE", run_name="test" )
Error: “API Key access denied” (403)
Symptoms:
ValueError: ❌ API Key access denied. Your API key may not have the required permissions.Solutions:
- Check key permissions - Some keys may have restricted access
- Get a new key from the web dashboard
- Contact support if issue persists
Project Errors
Error: “Project ‘X’ not found”
Symptoms:
ValueError: Project 'MyProject' not found. Available projects: [...]Solutions:
-
Use auto-create:
with optixlog.run( "my_run", project="NewProject", create_project_if_not_exists=True # Default: True for optixlog.run() ) as client: pass -
List available projects:
projects = optixlog.list_projects(api_url, api_key) for p in projects: print(p.name) -
Create project manually:
optixlog.create_project(api_url, api_key, "NewProject")
Error: “Failed to create project”
Symptoms:
ValueError: ❌ Failed to create project (500): ...Solutions:
- Check if project already exists (may be owned by another user)
- Try a different project name
- Check server status
Network Connectivity Issues
Error: “Cannot connect to OptixLog server”
Symptoms:
ValueError: Cannot connect to OptixLog serverSolutions:
-
Check internet connection:
ping backend.optixlog.com -
Verify API URL:
# Default URL api_url = "https://backend.optixlog.com" # Or set custom export OPTIX_API_URL="https://your-custom-url.com" -
Check firewall/proxy:
- Ensure port 443 (HTTPS) is open
- Configure proxy if needed
-
Test connection:
import requests try: r = requests.get("https://backend.optixlog.com/health", timeout=5) print(f"Server status: {r.status_code}") except Exception as e: print(f"Connection failed: {e}")
MPI Detection Problems
Issue: MPI Not Detected
Symptoms:
is_masteris alwaysTruerankis always0sizeis always1
Solutions:
-
Check environment variables:
# OpenMPI echo $OMPI_COMM_WORLD_RANK echo $OMPI_COMM_WORLD_SIZE # Intel MPI echo $PMI_RANK echo $PMI_SIZE -
Install mpi4py:
pip install mpi4py -
Verify MPI installation:
mpirun --version which mpirun -
Test MPI:
try: from mpi4py import MPI comm = MPI.COMM_WORLD print(f"Rank: {comm.Get_rank()}, Size: {comm.Get_size()}") except ImportError: print("mpi4py not installed")
Issue: All Processes Logging
Symptoms: Duplicate logs from all MPI processes
Solution: Always check is_master:
with optixlog.run("parallel") as client:
if client.is_master:
client.log(step=step, value=value)File Upload Failures
Error: “File not found”
Symptoms:
ValueError: ✗ Invalid file: File not found: /path/to/file.csvSolutions:
-
Check file path:
import os path = "results.csv" if os.path.exists(path): client.log_file("results", path) else: print(f"File not found: {path}") -
Use absolute paths:
import os abs_path = os.path.abspath("results.csv") client.log_file("results", abs_path) -
Check permissions:
import os if os.access("results.csv", os.R_OK): client.log_file("results", "results.csv")
Error: “Upload failed”
Symptoms:
MediaResult(key='file', ✗ Upload failed (413))Solutions:
- Check file size - May exceed server limits
- Compress large files before uploading
- Split large files into smaller chunks
- Check network connection
Image Format Issues
Error: “Invalid image”
Symptoms:
MediaResult(key='plot', ✗ Invalid image: ...)Solutions:
-
Use helper method (recommended):
# Automatically handles conversion client.log_matplotlib("plot", fig) -
Check PIL Image format:
from PIL import Image img = Image.open("plot.png") print(f"Format: {img.format}, Size: {img.size}, Mode: {img.mode}") -
Convert to RGB if needed:
if img.mode != 'RGB': img = img.convert('RGB') client.log_image("plot", img)
Validation Errors
Error: “Invalid metrics: NaN detected”
Symptoms:
MetricResult(step=0, ✗ Invalid metrics: NaN detected in 'loss')Solutions:
-
Check for NaN/Inf:
import numpy as np value = calculate_value() if np.isfinite(value): client.log(step=0, value=value) else: print(f"Warning: Invalid value {value}") -
Replace NaN with default:
value = calculate_value() if np.isnan(value): value = 0.0 # or appropriate default client.log(step=0, value=value) -
Use numpy functions:
value = np.nan_to_num(calculate_value(), nan=0.0) client.log(step=0, value=value)
Error: “Invalid step: Step must be non-negative”
Symptoms:
MetricResult(step=-1, ✗ Invalid step: Step must be non-negative)Solution:
# Ensure step is non-negative
step = max(0, calculated_step)
client.log(step=step, value=value)Performance Issues
Issue: Slow Logging
Symptoms: Logging takes too long, slows down simulation
Solutions:
-
Use batch operations:
# Slow for step in range(1000): client.log(step=step, loss=losses[step]) # Fast metrics = [{"step": i, "loss": losses[i]} for i in range(1000)] client.log_batch(metrics) -
Reduce logging frequency:
# Log every 10 steps instead of every step for step in range(1000): if step % 10 == 0: client.log(step=step, loss=losses[step]) -
Log asynchronously (if supported):
# Queue logs and upload in background # (Implementation depends on your needs)
Issue: High Memory Usage
Symptoms: Memory usage grows during logging
Solutions:
-
Close matplotlib figures:
fig, ax = plt.subplots() # ... plot code ... client.log_matplotlib("plot", fig) plt.close(fig) # Important! -
Use helper methods (auto-cleanup):
# Helper methods automatically close figures client.log_plot("plot", x, y) -
Clear large arrays after logging:
field = get_field() client.log_array_as_image("field", field) del field # Free memory
Common Error Messages
”Server error (500)”
Cause: Internal server error
Solutions:
- Wait a moment and retry
- Check server status
- Contact support if persistent
”Server error (404)”
Cause: Endpoint not found
Solutions:
- Check API URL is correct
- Verify you’re using the latest SDK version
- Check server is running
”Timeout”
Cause: Request took too long
Solutions:
- Check network connection
- Reduce file sizes
- Use batch operations for efficiency
Getting Help
If you encounter an issue not covered here:
- Check the error message - It often contains helpful hints
- Verify your setup - API key, project, network
- Check SDK version:
import optixlog print(optixlog.__version__) - Update SDK:
pip install --upgrade http://optixlog.com/optixlog-0.0.4-py3-none-any.whl - Report the issue with:
- Error message
- SDK version
- Python version
- Code snippet (if possible)