Skip to main content

Data-driven and Reactive programming framework

Project description

0.2.0 alpha

* Data-driven programming framework
* Paralleled in coroutines and ThreadPool
* Type- and content-based route function
* Interactive programming with Jupyter Notebook


Install and update using ``pip``:

`pip install -U botflow`


What's data-driven programming?

All functions are connected by pipes (queues) and communicate by data.

When data come in, the function will be called and return the result.

Think about the pipeline operation in unix: ``ls|grep|sed``.


#. Decouple data and functionality
#. Easy to reuse

Botflow provides pipe and route. It makes data-driven programming and powerful data flow processes easier.

Botflow is...

- **Simple**

Botflow is easy to use and maintain, *does not need configuration files*, and knows about ``asyncio`` and how to parallelize computation.

Here's one of the simple applications you can make:

_Load the price of Bitcoin every 2 seconds. Advantage price aggregator sample can be found `here <>`_.

.. code-block:: python

from botflow import *

def main():

Timer(delay=2), # send timer data to pipe every 2 seconds
"", # send url to pipe when timer trigger
HttpLoader(), # read url and load http response
lambda r: r.json['bpi']['USD']['rate_float'], # read http response and parse as json
print, # print out



**Or write in chain style**

.. code-block:: python

from botflow import *
.HttpLoader().Map(lambda r: r.json['bpi']['USD']['rate_float']).Map(print)

- **Http server Support OOB** Publish your data pipe to public quickly.

.. code-block:: python

from botflow import *
from aiohttp import web

p = Pipe(

{"msg":"hello world!"}

app = web.Application()

web.get('/', p.aiohttp_json_handle)

#BotFlow start web server

- **Flow Graph**
With render function:
Botflow will render the data flow network into a graphviz image.
below is the flow graph generated by Botflow.Aggreate 6 exchanges bitcoin price for trading.

.. image:: docs/bitcoin_arbitrage.png
:width: 400

- **Fast**
Nodes will be run in parallel, and they will perform well when processing stream data.
:Web Crawle: Botflow is 10x fatter than Scrapy

- **Replay-able**

With replay mode enabled:
when an exception is raised at step N, you don't need to run from setup 1 to N.
Botflow will replay the data from nearest completed node, usually step N-1.
It will save a lot of time in the development phase.


:**0.2.0**: Milestone release.:

# Jupyter support. Able to run inside Jupyter note book.

# pipe can be nest in another Pipe.


# Support Chain style pipe line creating.

Pipe(range(1,10)).Map(lambda x:x+1).Fiter(lambda x:x>2)

same as :

Pipe(range(1,10),lambda x:x+1,Filter(lambda x:x>2))

:**0.1.9**: Major change see below .:

# Backpressure rate limit support

# Httpserver support

# new Node support. *Zip*, *SendTo* *Flat* for make loop and redirect the flow

# Type hints support .for function type route

# reorge the source code for readable.

:**0.1.8**: .:

#. Support parallel in ThreadPool for slow function.

#. Loop Node is deprecated. raw value and Iterable value can be used directly.

#. improve performance of BlockedJoin


- Will add Httpserver support(REST,Websocket).
- Will support server machine learning Model online.
- Finshe the api reference doc.
- Rename project to Botflow.?

More about Botflow

Data-driven programming is typically applied to streams of structured data for filtering, transforming, aggregating (such as computing statistics), or calling other programs.

Botflow has a few basic concepts to implement Data-driven programming .

- **Source**
It is feed stream data to the pipe.

* **Timer**: It will send a message in the pipe by timer param. **delay**, **max_time** **until** some finished
* ****: you can use to trigger the data into pipe. By default it will feed int **0**

- **Function**
It is callable unit.Any callable function and object can work as Node. It is driven by data. Custom functions work as Map unit.
There are some built-in nodes:

* **Fetch**: (Alias:HttpLoader) Get a url and return the HTTP response
* **AioFile**: for file I/O.
* **SpeedLimit**: limit the stream speed limit
* **Delay**: delay in special second.
* **Map** : Work ad Convert unit.
* **Filter** : Drop data from pipe if it does not match some condition
* **Flat** : Drop data from pipe if it does not match some condition

- **Route**
It will be used to create a complex data flow network, not just one main process. Botflow can nest Routes inside Routes.
It is a powerful concept.
There are some pre built-in Route:
* **Pipe**: It is the main stream process of the program. All units will work inside.
* **Tee** : (Alias:Branch) Duplicate data from parent pipe to a child pipe as branch.
* **Zip** : Combine multi pipes result to list.
* **Link**: (Alias: LinkTo) Route flow to any Node or Route for making loop , circle

All units (Pipe, Node, Route) communicate via queues and perform parallel computation in coroutines.
This is abstracted so that Botflow can be used with only limited knowledge of ``asyncio``.




Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for botflow, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size botflow-0.2.0-py3-none-any.whl (31.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size botflow-0.2.0.tar.gz (26.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page