smithery/comet-ml

python-sdk

Python SDK patterns for Opik. Use when working in sdks/python, on SDK APIs, integrations, or message processing.

Installation

$ npx skills add smithery/comet-ml --skill python-sdk

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/comet-ml.

npx skills add smithery/comet-ml

Browse all from smithery/comet-ml

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Skill metadata

Parsed from SKILL.md frontmatter.

Declared agents claude-code

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,750 B
  • docs SUMMARY.md 130 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

Python SDK

Three-Layer Architecture

Layer 1: Public API      (opik.Opik, @opik.track)
    ↓
Layer 2: Message Processing   (queue, batching, retry)
    ↓
Layer 3: REST Client     (OpikApi, HTTP)

Critical Gotchas

Flush Before Exit

# ✅ REQUIRED for async operations
client = opik.Opik()
# ... tracing operations ...
client.flush()  # Must call before exit!

Async vs Sync Operations

Async (via message queue) - fire-and-forget:

  • trace(), span()
  • logtracesfeedback_scores()
  • experiment.insert()

Sync (blocking, returns data):

  • createdataset(), getdataset()
  • createprompt(), getprompt()
  • searchtraces(), searchspans()

Lazy Imports for Integrations

# ✅ GOOD - integration files assume dependency exists
import anthropic  # Only imported when user uses integration

# ❌ BAD - importing at package level
from opik.integrations import anthropic  # Would fail if not installed

Integration Patterns

Pattern Selection

Library has callbacks? → Pure Callback (LangChain, LlamaIndex)
No callbacks?         → Method Patching (OpenAI, Anthropic)
Callbacks unreliable? → Hybrid (ADK)

Method Patching (OpenAI, Anthropic)

from opik.integrations.anthropic import track_anthropic

client = anthropic.Anthropic()
tracked_client = track_anthropic(client)  # Wraps methods

Callback-Based (LangChain)

from opik.integrations.langchain import OpikTracer

tracer = OpikTracer()
chain.invoke(input, config={"callbacks": [tracer]})

Decorator-Based

@opik.track
def my_function(input: str) -> str:
    # Auto-creates span, captures input/output
    return process(input)

Dependency Policy

  • Avoid adding new dependencies
  • Use conditional imports for integrations
  • Keep version bounds flexible: >=2.0.0,<3.0.0

Batching System

Messages batch together for efficiency:

  • Flush triggers: time (1s), size (100), memory (50MB), manual
  • Reduces HTTP overhead significantly

API Method Naming

# CRUD: create/get/list/update/delete
client.create_experiment(name="exp")
client.get_dataset(name="ds")

# Search for complex queries
client.search_spans(project_name="proj")
client.search_traces(project_name="proj")

# Batch for bulk operations
client.batch_create_items(...)

Reference Files

  • [testing.md](testing.md) - fake_backend, verifiers, test naming
  • [error-handling.md](error-handling.md) - Exception hierarchy, MetricComputationError
  • [good-code.md](good-code.md) - Access control, imports, factories, DI