Skip to main content
License PyPI Python Versions
https://raw.githubusercontent.com/42Crunch/powerful-pipes/main/docs/logo-250x250.png

In a nutshell Powerful Pipes is a library for working with UNIX Pipes.

Install

> pip install powerful-pipes

Quick Start

Create a CLI tool that reads from the JSON from stdin and dumps to the stdout, after processing input data:

# File: pipe-example.py
from powerful_pipes import read_json_from_stdin, eprint, write_json_to_stdout

for error, input_json in read_json_from_stdin():

    if error:
        # Here you can manager the error. Most common error is that the
        # input is not a valid json.
        # eprint(...) function dumps the error message to the stderr
        eprint(message="Error processing input from stdin")
        continue

    try:
        input_json["myData"] = "data 1"

    except Exception as e:
        report_exception(input_json, e)

    finally:
        # THIS STEP IS CRITICAL. If you don't put again in the stdout the
        # input data, following tools in the pipe chain wouldn't receive
        # the data
        write_json_to_stdout(input_json)

Using in CLI:

> echo '{}' | python pipe-example.py | jq
{
    "myData": "data 1"
}

Advanced Usage

If you need to pass heavy data between tools in the pipe chain, you should use the write_to_stdout_by_file_ref and read_from_stdin_by_file_ref.

It stores the data in a temporary file and passes the file reference to the next tool in the pipe chain.

# File: pass_by_reference.py
from powerful_pipes import read_from_stdin_by_file_ref, eprint, write_to_stdout_by_file_ref, report_exception

for error, input_json in read_from_stdin_by_file_ref():

    if error:
        # Here you can manager the error. Most common error is that the
        # input is not a valid json.
        # eprint(...) function dumps the error message to the stderr
        eprint(message="Error processing input from stdin")
        continue

    try:
        input_json["myData"] = "data 1"

    except Exception as e:
        report_exception(input_json, e)

    finally:
        # THIS STEP IS CRITICAL. If you don't put again in the stdout the
        # input data, following tools in the pipe chain wouldn't receive
        # the data
        write_to_stdout_by_file_ref(input_json)

Changelog

You can check Changelog.

Documentation

You can find the complete documentation at: Documentation

Authors

Powerful Pipes was made by 42Crunch Research Team:

License

Powerful Pipes is Open Source and available under the Apache 2.

Contributions

Contributions are very welcome. See CONTRIBUTING.md or skim existing tickets to see where you could help out.

Acknowledgements

Special thanks to Cesar Gallego for his mentoring in data processing, that inspired this project.

Project logo thanks to Pipe icons created by srip - Flaticon

Metadata

Release files for powerful-pipes 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for powerful-pipes 1.1.3
File Size Uploaded
powerful-pipes-1.1.3.tar.gz 13.4 kB Details

Release files / powerful-pipes-1.1.3.tar.gz

Download URL powerful-pipes-1.1.3.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ef34277e110ff7d03ddef6fe864a6a358a19694e59d37bf9dc74d9ffde37c512
BLAKE2b-256 checksum
How to use checksums
52ef9bd5f27b3c9049e7986407ce301664c477affa7dfded000fefd949c86187
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release history Release notifications | RSS feed

This release

1.1.3 This release

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page