Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1kbgz Tributary Streaming Output Sinks

From Leeroopedia
Knowledge Sources
Domains Streaming, Data_Output
Last Updated 2026-10-14 00:00 GMT

Overview

Concrete streaming output sink functions for consuming data from Tributary streaming pipelines, provided by the Tributary library.

Description

The output sink functions consume an upstream Node and produce side effects. Print writes to stdout, Collect accumulates values into a list, GraphViz renders the graph, Dagre provides interactive visualization, Logging logs via Python's logging module, and Perspective displays data in a Perspective widget.

External output sinks (File, HTTP, Kafka, Postgres, Email, TextMessage, WebSocket, SSE, SocketIO, Queue) are provided in sibling modules.

Usage

Import these functions when you need to consume a streaming pipeline's output. Use Print for debugging, Collect for testing, and the external sinks for persistence or notification.

Code Reference

Source Location

  • Repository: Tributary
  • File: tributary/streaming/output/output.py

Signature

def Print(node, text=""):
    """Print stream values to stdout with optional label prefix."""

def Logging(node, level=logging.CRITICAL):
    """Log stream values via Python's logging module."""

def Collect(node, limit=None):
    """Collect stream values into a list, optionally capped to limit."""

def Graph(node):
    """Return nested dict representation of the graph."""

def GraphViz(node):
    """Return a graphviz.Digraph rendering of the graph."""

def Dagre(node):
    """Return an ipydagred3.DagreD3Widget for interactive visualization."""

def Perspective(node, text="", **psp_kwargs):
    """Display stream data in a PerspectiveWidget."""

def Queue(node, queue):
    """Push stream values into an asyncio Queue."""

Import

from tributary.streaming import Print, Collect, Logging, Perspective, Queue
from tributary.streaming.output.output import GraphViz, Dagre, Graph

I/O Contract

Inputs

Name Type Required Description
node Node Yes Upstream streaming node to consume
text str No (Print) Label prefix for printed output
limit int No (Collect) Maximum number of items to retain
level int No (Logging) Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
queue asyncio.Queue Yes (Queue) Queue to push values into

Outputs

Name Type Description
return Node A sink Node that consumes the stream
Collect result list The list of collected values (accessible via node.value())
GraphViz result graphviz.Digraph A Digraph object for rendering
Dagre result DagreD3Widget An interactive graph widget

Usage Examples

Print Sink

import tributary.streaming as ts

source = ts.Const(value="hello", count=3)
out = Print(source, text="Value: ")
ts.run(out)
# Output: Value: hello, Value: hello, Value: hello

Collect Sink

import tributary.streaming as ts

source = ts.Curve(value=[1, 2, 3, 4, 5])
collected = Collect(source)
ts.run(collected)
print(collected.value())  # [1, 2, 3, 4, 5]

Collect with Limit

import tributary.streaming as ts

source = ts.Curve(value=[1, 2, 3, 4, 5, 6, 7])
collected = Collect(source, limit=3)
ts.run(collected)
print(collected.value())  # [5, 6, 7] (last 3)

Related Pages

Implements Principle

Requires Environment

Page Connections

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