OptixLog CLI Overview
The OptixLog CLI is a command-line interface for auto-instrumenting Python code and managing OptixLog experiments from the terminal.
What is OptixLog CLI?
OptixLog CLI is a Node.js-based tool that:
- Auto-instruments code - Automatically adds OptixLog logging to Python scripts and Jupyter notebooks
- Manages configuration - Stores API keys and settings in
.optixlog.json - Integrates with SDK - Automatically detects and installs the Python SDK
- Queries runs - List and manage experiments from the terminal
- Smart code generation - Uses new SDK helpers for zero-boilerplate logging
Key Features
Auto SDK Detection
The CLI automatically detects if the OptixLog Python SDK is installed and offers to install it if missing:
$ optixlog add-logging script.py
⚠ OptixLog SDK not found in Python environment
⚙ Installing OptixLog SDK...
✓ SDK installed successfully!Config Management
Store your API key and project settings in .optixlog.json:
optixlog init --project "MyProject" --api-key "proj_xxx"Smart Code Generation
The CLI can generate code using new SDK helper methods:
optixlog add-logging script.py --smartThis generates code with:
- Context manager (
with optixlog.run()) - Helper methods (
log_matplotlib(),log_plot(), etc.) - Helpful comments and suggestions
Query Commands
List and manage runs from the terminal:
optixlog runs --project "MyProject" --limit 10Use Cases
Quick Instrumentation
Add logging to existing Python scripts in seconds:
optixlog add-logging my_simulation.py
python my_simulation.pyTeam Collaboration
Share configuration files (without API keys) in version control:
# Team member 1
optixlog init --project "TeamProject" --local
# Commits .optixlog.json (without API key)
# Team member 2
optixlog config set api_key "proj_their_key"
optixlog add-logging shared_code.pyBatch Processing
Instrument multiple files at once:
for file in *.py; do
optixlog add-logging "$file"
doneCI/CD Integration
Automate instrumentation in CI pipelines:
# In CI script
optixlog init --project "CI_Runs"
optixlog add-logging test_script.py
python test_script.pyArchitecture
The CLI is built with:
- Node.js - Runtime environment
- Commander.js - CLI framework
- Axios - HTTP client for backend communication
- TypeScript - Type-safe development
CLI vs SDK
| Feature | CLI | SDK |
|---|---|---|
| Purpose | Code instrumentation | Runtime logging |
| When to use | Before running code | During code execution |
| Language | Node.js/TypeScript | Python |
| Installation | npm install -g optixlog-cli | pip install http://optixlog.com/optixlog-0.0.4-py3-none-any.whl |
| Workflow | Transform code → Run | Log during execution |
Typical workflow:
- CLI - Instrument your code:
optixlog add-logging script.py - SDK - Run instrumented code:
python script.py(SDK logs automatically)