Skip to main content
  • For retryable requests, Weave retries requests starting at 1 second after receiving the first error and then doubles the amount of time between attempts up to 5 minutes. Requests timeout after 36 hours.
  • Instead of raising exceptions, .call() captures exceptions and stores them in the call.exception. If you need to raise exceptions during execution, set the __should_raise parameter, like this:
    showLineNumbers
    # This raises exceptions
    result, call = foo.call(__should_raise=True)
    
  • Dedicated Weave instances use a different OpenTelemetry ingress URL. See Send OpenTelemetry Traces for authoritative endpoint information.
  • Weave sometimes truncates large trace data objects. This occurs because default trace output is a raw, custom Python object that Weave doesn’t know how to serialize. To return all of your trace data, define a dictionary of strings, like this:
    import weave
    
    class MyObj:
        """An object with a large string attribute."""
        def __init__(self, x: int):
            self.x = x
    
        def __repr__(self):
            return f"MyObj(x={self.x})"
    
        def to_dict(self):
            return {"x": self.x}
    
    @weave.op()
    def make_my_obj():
        x = "a" * 10_000
        return MyObj(x)
    
    def main():
        weave.init("<entity/project>")
    
        # Define a traceable operation that processes MyObj
        @weave.op()
        def process_obj(obj: MyObj) -> int:
            return len(obj.x)
    
        # Create and process a large MyObj instance
        large_obj = make_my_obj()
        length = process_obj(large_obj)
        print(f"Length of x in MyObj: {length}")
        print("dict:", large_obj.to_dict())
    
    if __name__ == "__main__":
        main()