8000 GitHub - linjh8571/botflow: Python Fast Data driven programming framework for Data pipeline work( Web Crawler,Machine Learning,Quantitative Trading.etc) · GitHub
[go: up one dir, main page]

Skip to content
linjh8571Public
forked from kkyon/botflow

About

Python Fast Data driven programming framework for Data pipeline work( Web Crawler,Machine Learning,Quantitative Trading.etc)

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

180 Commits

Folders and files

Repository files navigation

Botflow

  • Data-driven programming framework
  • Paralleled in coroutines and ThreadPool
  • Type- and content-based route function

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:

  1. Decouple data and functionality
  2. 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.

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()
  • Http server Support OOB Publish your data pipe to public quickly.
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.

docs/bitcoin_arbitrage.png

  • 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.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 .:

  1. Support parallel in ThreadPool for slow function.
  2. Loop Node is deprecated. raw value and Iterable value can be used directly.
  3. improve performance of BlockedJoin
0.1.7:

RoadMap

  • Will add Httpserver support(REST,Websocket).
  • Will support server machine learning Model online.
  • Fins 6F71 he 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 .

  • Pipe

    It is the main stream process of the program. All units will work inside.

  • Node

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

    • Timer: It will send a message in the pipe by timer param. delay, max_time until some finished
    • 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.
    • Zip : Wait for all branched to finish and merged the result into a tuple.
    • Filter : 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:

    • Branch : Duplicate data from parent pipe to a branch.
    • Line : Extend the length of route.
    • Join : Duplicate data to many branches, and return result to pipe.
    • 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

About

Python Fast Data driven programming framework for Data pipeline work( Web Crawler,Machine Learning,Quantitative Trading.etc)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0