Coder Social home page Coder Social logo

rcorrero / light-pipe Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 1.53 MB

A high-level syntax for data pipelines, designed to make pipeline development quick and painless.

Home Page: https://www.light-pipe.io/

License: BSD 3-Clause "New" or "Revised" License

Python 98.63% Shell 1.37%
geospatial-analysis geospatial-processing pipeline data data-pipelines data-processing

light-pipe's Introduction


Overview

Light-Pipe is a high-level syntax for data pipelines, designed to make pipeline development quick and painless. It is an extensible, light-weight Python framework with zero non-standard dependencies for data pipelines that scale effortlessly. It abstracts away the implementation details of the pipeline itself, meaning that the developer only has to define the transformations performed within the pipeline on individual units of data.

Pipelines defined using Light-Pipe scale effortlessly, with native support for all forms of concurrency, allowing for the mixing and matching of asynchronous, multi-threaded, and multi-process operations all within a single pipeline. It's easily extensible for use with distributed processing services such as Celery. It's also super fast and efficient, having been used to perform critical geospatial data processing tasks at least an order of magnitude faster than existing systems.

Light-Pipe is released under a BSD-3-Clause License.

Installing Light-Pipe

$ pip install light-pipe

A Basic Example

>>> from light_pipe import make_data, make_transformer
>>> 
>>> 
>>> @make_data
>>> def gen_dicts(x: int):
>>>     for i in range(x):
>>>         yield {
>>>             "one": 3 * i, 
>>>             "two": 3 * i + 1, 
>>>             "three": 3 * i + 2
>>>         }
>>> 
>>> @make_transformer
>>> def get_third(one: int, two: int, three: int):
>>>     print(f"Third: {three}")
>>>     return three
>>> 
>>> 
>>> data = gen_dicts(x=3, store_results=True)
>>> data >> get_third()
>>> 
>>> print(data(block=True))
Third: 2
Third: 5
Third: 8
[2, 5, 8]
>>>
>>> print(data(block=True))
[2, 5, 8]

A (Slightly) More Interesting Example

>>> import asyncio
>>> import time
>>> 
>>> from light_pipe import AsyncGatherer, make_data, make_transformer
>>> 
>>> 
>>> @make_data
>>> def gen(x: int):
>>>     yield from range(x)
>>> 
>>> 
>>> @make_transformer
>>> async def add_one(x: int):
>>>     await asyncio.sleep(1)
>>>     return x + 1
>>> 
>>> 
>>> data = gen(x=8)
>>> 
>>> t = add_one(parallelizer=AsyncGatherer())
>>> 
>>> 
>>> for _ in range(10):
>>>     data >> t
>>> 
>>> start = time.time()
>>> print(data(block=True))
[12, 10, 14, 11, 16, 15, 13, 17]
>>> 
>>> end = time.time()
>>> diff = end - start
>>> print(f"Total time to execute tasks: {diff:.1f} seconds.")
Total time to execute tasks: 10.0 seconds.

More Information


Copyright 2020-2023 Richard Correro.

light-pipe's People

Contributors

rcorrero avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

stanford-htdl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.