In [1]:
import asyncio
import random
import tributary.streaming as ts
In [2]:
# Return a random value
def func():
    return random.random()
In [3]:
# Call the random function 5 times
rand = ts.Timer(func, interval=0, count=5)

# Multiply by a constant
rand_perc = rand * 100

# Round to 2 digits
rand_rounded = rand_perc.apply(lambda x: round(x, 2))

# And print the result
p = rand_rounded.print()
In [4]:
p.dagre()
Out[4]:
DagreD3Widget()
In [5]:
# for static export
p.graphviz()
Out[5]:
Graph Print#5c3cb Print#5c3cb Apply#feff5 Apply#feff5 Apply#feff5->Print#5c3cb Mult#cd501 Mult#cd501 Mult#cd501->Apply#feff5 Timer[func]#0d167 Timer[func]#0d167 Timer[func]#0d167->Mult#cd501 Const[100] Const[100] Const[100]->Mult#cd501
In [6]:
res = ts.run(p)
In [ ]: