Skip to main content

API Overview


class DisplayNameFuncError


class OpCallError


class OpKwargs

TypedDict for op() keyword arguments.

class Sentinel

Sentinel(package: ‘str’, path: ‘str’, name: ‘str’)

method __init__


class WeaveKwargs


function as_op

Given a @weave.op decorated function, return its Op. @weave.op decorated functions are instances of Op already, so this function should be a no-op at runtime. But you can use it to satisfy type checkers if you need to access OpDef attributes in a typesafe way. Args:
  • fn: A weave.op decorated function. Returns: The Op of the function.

function call

Executes the op and returns both the result and a Call representing the execution. This function will never raise. Any errors are captured in the Call object. This method is automatically bound to any function decorated with @weave.op, allowing for usage like:

function calls

Get an iterator over all calls to this op. This method is automatically bound to any function decorated with @weave.op, allowing for usage like:

function get_captured_code

Get the captured code of the op. This only works when you get an op back from a ref. The pattern is: ref = weave.publish(func) op = ref.get() captured_code = op.get_captured_code()

function is_op

Check if an object is an Op.

function is_placeholder_call


function is_tracing_setting_disabled


function maybe_bind_method

Bind a function to any object (even if it’s not a class). If self is None, return the function as is.

function maybe_unbind_method

Unbind an Op-like method or partial to a plain Op function. For:
  • methods, remove set self param
  • partials, remove any preset params

function op

A decorator to weave op-ify a function or method. Works for both sync and async. Automatically detects iterator functions and applies appropriate behavior. Args:

function placeholder_call


function setup_dunder_weave_dict

Sets up a __weave dict used to pass WeaveKwargs to ops.
  • func: The function to decorate.
  • name: Custom name for the op. Defaults to the function name.
  • call_display_name: Display name for calls, can be a string or callable.
  • postprocess_inputs: Function to transform inputs before logging.
  • postprocess_output: Function to transform output before logging.
  • tracing_sample_rate: Fraction of calls to trace (0.0 to 1.0).
  • enable_code_capture: Whether to capture source code for this op.
  • accumulator: Function to accumulate results for streaming ops.
  • attributes: Default attributes merged into every call this op creates, at the lowest precedence. A weave.attributes() context and explicit per-call attributes override them on key collision. The reserved “weave” key may not be set here.
  • eager_call_start: If True, call starts are sent immediately rather than batched. Useful for long-running operations like evaluations that should be visible in the UI immediately. Args:
  • d: Optional existing WeaveKwargs dict to update.
  • op: Op to extract kind and color from. Returns: WeaveKwargs dict with attributes, display_name, and optionally kind/color set.

function should_skip_tracing_for_op