Skip to main content

Composable ETL Logic Layer

Project description

PETaL - Python Extract Transform and Load

A framework to compose custom ETLs on top of a logical floor.

Follow along in the /examples directory to build up arbitrary pipelines.

(This is modeled on Airflow's DAG Operator model for intuitive composition in Python.)

01. Trivial Case

# The most trivial pipeline possible
with Pipeline("01_noop") as dag:  # Define the pipeline context manager, inner block gets scoped to this object
    source = EmptySource("empty_source")  # Define operators
    sink = NoOpSink("no_op_sink")

    source >> sink  # Compose the operators into a DAG

dag.run()

02. Simple Case - Single ETL Step

# A single ETL step
with Pipeline("02_copy_file_to_file") as dag:
    read_logs = FileReader("read_logs", file_path="../data/example_input.txt")
    pattern_filter = RegexFilter("filter_info", pattern="^INFO")
    write_to_file = FileWriter("write_file", file_path="../data/example_output.txt")

    read_logs >> pattern_filter >> write_to_file

dag.run()

03. One Source, Multiple Sinks

    with Pipeline("03_splitting_streams_to_multiple_destinations") as dag:
        read_logs = FileReader("read_logs", file_path="../data/example_input.txt")
        # Fan-out operator that can be used to split the stream into multiple threads
        splitter = Splitter("split")
        
        # One branch will be just a direct copy
        write_to_file_unfiltered = FileWriter("write_unfiltered", file_path="../data/example_output_unfiltered.txt")
        
        # The other branch will be nice and filtered
        pattern_filter = RegexFilter("filter_info", pattern="^INFO")
        write_to_file_filtered = FileWriter("write_filtered", file_path="../data/example_output_filtered.txt")
        

        # Read the logs into the splitter...
        read_logs >> splitter
        
        # ...then read as many branches from the splitter as you want
        splitter >> pattern_filter >> write_to_file_filtered
        splitter >> write_to_file_unfiltered

    dag.run()

Theory

There are 3 types of Operators - Sources, Sinks, and Non-Terminal Operators. Pipelines in Petal are wrappers around arbitrary Directed Acyclic Graphs (DAGs). A Pipeline is constructed from a DAG and has the following invariants:

  1. It must have at least 1 Operator satisfying each of the terminal operator types (ie. at least 1 Source and 1 Sink).
  2. Operators are directional (data flows in a particular direction within the Operator).
  3. Each Operator has a unique ID and a reference to its upstream and downstream Operators.
  4. There are no cycles in the graph.

Project details


Download files

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

Source Distribution

petal_etl_composer-0.1.3.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

petal_etl_composer-0.1.3-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file petal_etl_composer-0.1.3.tar.gz.

File metadata

  • Download URL: petal_etl_composer-0.1.3.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.1

File hashes

Hashes for petal_etl_composer-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e9569273cd2af6f5f104e951d3e52e252b058e9f77b79c7fc109b501f9ef3fa8
MD5 ac6cd9ee21ea84f6330bc4a8524d7a5e
BLAKE2b-256 719eec8671e4be05c37951dd33d8e0ab4ce1b748cfb2b7cc7d1c07f11f1b2ae5

See more details on using hashes here.

File details

Details for the file petal_etl_composer-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for petal_etl_composer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 afcf7cad232756a1a41c030b2647975d0e57a7167eff3cc70136cc235f56eb72
MD5 08a4ec77767971b674d0a0de4b617f73
BLAKE2b-256 9837d6d92a1bedfc471cbfee8ef308e8d43aa3cfb09a6fb8d0b74ffa543a122c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page