Skip to main content

Documentation Index

Fetch the complete documentation index at: https://wb-21fd5541-weave-caching.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

API Overview


Source

class DisplayNameFuncError


Source

class OpCallError


Source

class OpKwargs

TypedDict for op() keyword arguments.
Source

class Sentinel

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

method __init__

__init__(package: 'str', path: 'str', name: 'str') → None

Source

class WeaveKwargs


Source

function as_op

as_op(fn: 'Callable[P, R]') → Op[P, R]
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.

Source

function call

call(
    op: 'Op',
    *args: 'Any',
    __weave: 'WeaveKwargs | None' = None,
    __should_raise: 'bool' = False,
    __require_explicit_finish: 'bool' = False,
    **kwargs: 'Any'
) → tuple[Any, Call] | Coroutine[Any, 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)

Source

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)

Source

function get_captured_code

get_captured_code(op: 'Op') → str
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()
Source

function is_op

is_op(obj: 'Any') → TypeIs[Op]
Check if an object is an Op.
Source

function is_placeholder_call

is_placeholder_call(call: 'Call') → TypeIs[NoOpCall]

Source

function is_tracing_setting_disabled

is_tracing_setting_disabled() → bool

Source

function maybe_bind_method

maybe_bind_method(func: 'Callable', self: 'Any' = None) → Callable | MethodType
Bind a function to any object (even if it’s not a class). If self is None, return the function as is.
Source

function maybe_unbind_method

maybe_unbind_method(oplike: 'Op | MethodType | partial') → Op
Unbind an Op-like method or partial to a plain Op function. For:
  • methods, remove set self param
  • partials, remove any preset params

Source

function op

op(
    func: 'Callable[P, R] | None' = None,
    name: 'str | None' = None,
    call_display_name: 'str | CallDisplayNameFunc | None' = None,
    postprocess_inputs: 'PostprocessInputsFunc | None' = None,
    postprocess_output: 'PostprocessOutputFunc | None' = None,
    tracing_sample_rate: 'float' = 1.0,
    enable_code_capture: 'bool' = True,
    accumulator: 'Callable[[Any | None, Any], Any] | None' = None,
    kind: 'OpKind | None' = None,
    color: 'OpColor | None' = None
) → Callable[[Callable[P, R]], Op[P, R]] | Op[P, R]
A decorator to weave op-ify a function or method. Works for both sync and async. Automatically detects iterator functions and applies appropriate behavior.
Source

function placeholder_call

placeholder_call() → Call

Source

function setup_dunder_weave_dict

setup_dunder_weave_dict(op: 'Op', d: 'WeaveKwargs | None' = None) → WeaveKwargs
Sets up a __weave dict used to pass WeaveKwargs to ops. 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.

Source

function should_skip_tracing_for_op

should_skip_tracing_for_op(op: 'Op') → bool