Botflow
=======
0.2.0 alpha
* Data-driven programming framework
* Paralleled in coroutines and ThreadPool
* Type- and content-based route function
* Interactive programming with Jupyter Notebook
Installing
----------
Install and update using ``pip``:
`pip install -U botflow`
Documentation
------------
http://botflow.readthedocs.io
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``.
Benefits:
#. 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 <https://github.com/kkyon/Botflow/tree/master/examples>`_.
.. code-block:: python
from botflow import *
def main():
Pipe(
Timer(delay=2), # send timer data to pipe every 2 seconds
"http://api.coindesk.com/v1/bpi/currentprice.json", # 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
)
Bot.render('ex_output/simple_bitcoin_price')
Bot.run()
main()
**Or write in chain style**
.. code-block:: python
from botflow import *
p_cd_bitcoin=Pipe().Timer(delay=2).Loop("http://api.coindesk.com/v1/bpi/currentprice.json")\
.HttpLoader().Map(lambda r: r.json['bpi']['USD']['rate_float']).Map(print)
p_cd_bitcoin.run()
- **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()
app.add_routes([
web.get('/', p.aiohttp_json_handle)
])
Bot.run_app(app)
#BotFlow start web server http://0.0.0.0:8080
- **Flow Graph**
With render function:
`Bot.render('bitcoin_arbitrage')`
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:
``config.replay_mode=True``
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.
Release
:**0.2.0**: Milestone release.:
# Jupyter support. Able to run inside Jupyter note book.
# pipe can be nest in another Pipe.
p1=Pipe(get_image)
p2=Pipe(get_price)
p_get_all=Pipe(Zip(p1,p2)).Filter
# 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**: http://docs.botflow.org/en/latest/change/0.1.8.html .:
#. Support parallel in ThreadPool for slow function.
#. Loop Node is deprecated. raw value and Iterable value can be used directly.
#. improve performance of BlockedJoin
:**0.1.7**:
RoadMap
=======
- 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
* **Pipe.run**: you can use Pipe.run 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``.
Contributing
------------
Donate
------
Links
-----
Metadata
Release files for botflow 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| botflow-0.2.0.tar.gz | 26.2 kB | Without provenance | Details for botflow-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| botflow-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for botflow-0.2.0-py3-none-any.whl |
Total release size: 57.9 kB
Release files / botflow-0.2.0.tar.gz
| Download URL | botflow-0.2.0.tar.gz |
|---|---|
| Size | 26.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fddbffb3d0abd3f6a4004c654ef00dd253d823d7669998de99b2b66dfa076b9a
|
|
BLAKE2b-256 checksum How to use checksums |
f5ebb4e606390a0d1e5d2387a4596dbacdd226bfbbf60850d0453aedf4b768eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
|
Release files / botflow-0.2.0-py3-none-any.whl
| Download URL | botflow-0.2.0-py3-none-any.whl |
|---|---|
| Size | 31.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d438de659e96f1c18871b2e3e3c614afc49d30f3c4defdff3972aa7cc3a0665c
|
|
BLAKE2b-256 checksum How to use checksums |
173ff0d2a8bfbde38777c77e243217d7b65eb1da1f2feb4b9024517dd042e025
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
|
Security for botflow 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.