Skip to main content

Returns

This method returns None.

Example

from galtea import set_context, clear_context

# Set context before running traced functions
token = set_context(inference_result_id="inf_123")

try:
    # Run traced functions...
    my_traced_function()
finally:
    # Clear context and flush traces (default behavior)
    clear_context(token)

Parameters

token
object
required
The context token returned by set_context().
flush
bool
If True (default), flush pending traces for the current inference result before clearing. Set to False to skip flushing.
Always use clear_context() in a finally block to ensure proper cleanup, even if an exception occurs.