Skip to content

Instantly share code, notes, and snippets.

@Stiivi
Created September 8, 2014 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Stiivi/f978ef316941c6f772ae to your computer and use it in GitHub Desktop.
Save Stiivi/f978ef316941c6f772ae to your computer and use it in GitHub Desktop.
Bubbles 0.3 (prototype 3) feature preview
from bubbles import Pipeline, ExecutionEngine
from bubbles import operation, datasource
# New implicit iterator operations
@datasource(fields=["i"])
def generator(context, count=10):
for i in range(count):
yield [i]
@operation
def add(context, src, amount=1):
for row in src:
yield [row[0]+amount] + row[1:]
@operation
def pretty_print(context, src):
for row in src:
print(row)
# New generative interface
p = Pipeline()
p.generator().add(amount=10).pretty_print()
# Execution responsibility moved to extensible/replacable execution engine
e = ExecutionEngine()
e.run(p.graph)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment