Skip to main content

A data pipeline library with connectors, sources, processors, and sinks.

Project description

Datapipelab

Overview

datapipelab is a lightweight, flexible data pipeline framework designed for building and orchestrating complex data workflows. It supports a modular node-based architecture, allowing users to plug in source, processor, and sink nodes using technologies such as Apache Spark, Google BigQuery, Hive, Delta Lake, and Microsoft Teams.

Installation

Clone the repository and install any required dependencies:

pip install -r requirements.txt

Or, if integrating as a module:

pip install datapipelab

Usage Guide

To run a pipeline, you typically follow these steps:

  1. Define your pipeline configuration using a Python list or a JSON config.
  2. Instantiate and execute the engine.

Example:

from datapipelab.engine import Engine

config = [
    {
        "type": "source",
        "format": "hive",
        "name": "load_customer_accounts",
        "options": {
            "query": "SELECT customer_id, enrollment_date FROM customer_account"
        }
    },
    {
        "type": "processor",
        "format": "spark",
        "name": "aggregate_active_users",
        "options": {
            "parents": ["load_customer_accounts"],
            "query": """
                SELECT 
                    YEAR(enrollment_date) AS enrollment_year, 
                    COUNT(*) AS active_user_count
                FROM load_customer_accounts
                GROUP BY enrollment_year
            """
        }
    },
    {
        "type": "sink",
        "format": "hive",
        "name": "store_active_user_report",
        "options": {
            "parents": ["aggregate_active_users"],
            "table": "report.active_user_summary"
        }
    },
    {
        "type": "sink",
        "format": "teams_notification",
        "name": "notify_report_ready",
        "options": {
            "parents": ["store_active_user_report"],
            "webhook_url": "{{{WEBHOOK_URL}}}",
            "message": "Active user report has been updated in Hive."
        }
    }
]

params = {"WEBHOOK_URL": "https://outlook.office.com/webhook/..."}
engine = Engine(config, spark, params)
engine.running_travelers()

Pipeline Configuration

Pipelines are defined using structured configuration objects or files that specify:

  • Nodes (source, processor, sink)
  • Dependencies and execution order via parents
  • Parameters for each node, e.g., SQL queries, table names, paths

Available Node Types

Source Nodes

  • spark_node

    • Executes a Spark SQL query to read data into the pipeline.

    • Example:

      {
        "name": "node_name",
        "type": "source",
        "format": "spark",
        "source": "spark",
        "options": {
          "query": "SELECT * FROM database_name.table_name"
        }
      }
      
  • hive_node

    • Reads data from a Hive table.

    • Example:

      {
        "name": "node_name",
        "type": "source",
        "format": "hive",
        "source": "hive",
        "options": {
          "query": "SELECT * FROM database_name.table_name"
        }
      }
      

Processor Nodes

  • bigquery_api_node

    • Executes a query via BigQuery API.

    • Example:

      {
        "name": "node_name",
        "type": "processor",
        "format": "bigquery_api",
        "options": {
              "credentials_path": "creadentials.json",
              "return_as_spark_df": false,
              "return_as_python_list": false,
              "return_as_is": true,
              "project_name": "project_name",
              "query": "select * from `project_name.dataset_name.table_name`"
        }
      }
      
      • *return_as_python_list and return_as_is are optional
      • *query can be any valid BigQuery SQL query including (SELECT/DDL/DML/Scripting/Control Flow/Stored Procedure Calls/Temporary Table Usage) statements.
  • gcp_bucket_api_node

    • Deletes a bucket or a directory in a GCP bucket.

    • Example:

      {
        "name": "node_name",
        "type": "processor",
        "format": "gcp_bucket_api",
        "options": {
              "credentials_path": "creadentials.json",
              "project_name": "project_name",
              "bucket_name": "bucket_name",
              "subdirectory": "path/to/subdirectory"
        }
      }
      
      • *subdirectory is optional and can be used to specify a subdirectory within the bucket.
  • bigquery_spark_node

    • Reads data from BigQuery using the Spark BigQuery connector.

    • Example:

      {
        "name": "node_name",
        "type": "processor",
        "format": "bigquery_spark",
        "options": {
              "parent_project": "parent_project_name",
              "materialization_dataset": "materialization_dataset_name",
              "query": "select * from `project_name.dataset_name.table_name`"
        }
      }
      
      • *query does not support DDL/DML/Scripting/Control Flow/Stored Procedure Calls/Temporary Table Usage statements. Only SELECT statements are supported.
  • shell_node

    • Executes a shell command or script.

    • Example:

      {
        "name": "node_name",
        "type": "processor",
        "format": "shell",
        "options": {
          "query": "echo 'Hello, World!'"
        }
      }
      
  • custom_node

    • Custom logic node written by user.

    • Example:

      {
        "name": "node_name",
        "type": "processor",
        "format": "custom",
        "options": {
          "module_name": "CustomModuleName"
          "module_path": "path/to/custom_module",
          "class_name": "CustomNodeClassName",
          "optional_param": "value"
        }
      }
      

Sink Nodes

  • hive_node

    • Writes output to a Hive table.

    • Example:

      {
        "name": "node_name",
        "type": "sink",
        "format": "hive",
        "type": "spark",
        "options": {
          "parents": ["parent_node_name"],
          "database": "database_name",
          "table": "table_name"
        }
      }
      
  • spark_node

    • Writes output to a Hive table.

    • Example:

      {
        "name": "node_name",
        "type": "sink",
        "format": "spark",
        "type": "spark",
        "options": {
          "parents": ["parent_node_name"],
          "database": "database_name",
          "table": "table_name"
        }
      }
      
  • teams_notification_node

    • Sends a message to a Microsoft Teams channel.

    • Example:

      {
        "type": "sink",
        "format": "teams_notification",
        "name": "notify_report_ready",
        "options": {
           "parents": ["store_active_user_report"],
           "webhook_url": "{{{WEBHOOK_URL}}}",
           "message": "Active user report has been updated in Hive."
        }
      }
      

Extending the Framework

To create a custom node:

  1. Subclass TNode from app/node/tnode.py
  2. Implement the required methods (run, validate, etc.)
  3. Register your node in the pipeline factory or configuration

Logging and Monitoring

Logging is centralized in logger.py. Logs are categorized by node and execution stage to assist with debugging and auditing.

Troubleshooting


For more advanced examples or integration guides, refer to the examples/ folder or reach out to the maintainers.

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

datapipelab-0.3.5.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

datapipelab-0.3.5-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file datapipelab-0.3.5.tar.gz.

File metadata

  • Download URL: datapipelab-0.3.5.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for datapipelab-0.3.5.tar.gz
Algorithm Hash digest
SHA256 8011e764e86c02fb07fcca55107483b8ad58fd1263fbca4dd5c3f07b5f42e14b
MD5 05bf9b47d1239f0a2dc20ae4104d32cd
BLAKE2b-256 864d1deaebce8a125f0de2c884c8eca09adda789845a987bd72dfd2214c69af4

See more details on using hashes here.

File details

Details for the file datapipelab-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: datapipelab-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for datapipelab-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d3d4f10695eb3e468efba5ff772681310b29c95179335e3341fa1e889f55a857
MD5 fc6ce8760e3a239730d3b73f48ae2cf3
BLAKE2b-256 d0cc6c5d3cedf69e2d99b2db5a211c2969041d4cd09c5d0e543da11b779a1a91

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