Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Wandb Weave Weave Finish

From Leeroopedia
Knowledge Sources
Domains Observability, Resource_Management
Last Updated 2026-02-14 00:00 GMT

Overview

Concrete tool for finalizing a Weave tracing session provided by the Wandb Weave library.

Description

The weave.finish() function flushes all pending trace data, unregisters import hooks, and clears the global client reference. After calling finish, no further traces will be recorded until weave.init() is called again.

Usage

Call this function at the end of a tracing session to ensure all trace data is flushed to the backend. This is especially important in short-lived scripts or serverless functions where the process may exit before buffered data is sent.

Code Reference

Source Location

  • Repository: wandb/weave
  • File: weave/trace/api.py
  • Lines: L386-398

Signature

def finish() -> None:
    """Stops logging to weave.

    Following finish, calls of weave.op decorated functions will
    no longer be logged. You will need to run weave.init() again
    to resume logging.
    """

Import

import weave

I/O Contract

Inputs

Name Type Required Description
(none) Uses global client state

Outputs

Name Type Description
return None No return value
side_effect flush Flushes all pending calls to the backend
side_effect unregister Removes import hooks
side_effect clear_client Clears global client reference

Usage Examples

Basic Session Lifecycle

import weave

# Start session
client = weave.init("my-team/my-project")

@weave.op
def process(x: str) -> str:
    return x.upper()

# Use traced functions
result = process("hello")

# End session - flush all pending data
weave.finish()

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment