Skip to main content

weave.trace.op

Defines the Op protocol and related functions.


API Overview

Functions

  • op.call: Executes the op and returns both the result and a Call representing the execution.
  • op.calls: Get an iterator over all calls to this op.

function call

call(op: Op, *args: Any, **kwargs: Any)tuple[Any, '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:

@weave.op
def add(a: int, b: int) -> int:
return a + b

result, call = add.call(1, 2)

function calls

calls(op: Op) → CallsIter

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:

@weave.op
def add(a: int, b: int) -> int:
return a + b

calls = add.calls()
for call in calls:
print(call)