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.6.tar.gz (13.7 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.6-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: datapipelab-0.3.6.tar.gz
  • Upload date:
  • Size: 13.7 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.6.tar.gz
Algorithm Hash digest
SHA256 357ab0e84a721ff1aa910445bd4da9ad4fb9daa8f3d5298a54c8be87eb98b2d3
MD5 16ff607ff94e46c05a0becd3b92d6bd7
BLAKE2b-256 33d88b8598d7f63950056458829b9402e7588642315fa28cae35a23330ef7a22

See more details on using hashes here.

File details

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

File metadata

  • Download URL: datapipelab-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 20.3 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 242412bce75a711e0358db7101d6f66e2569f706621886b645165dad028b36ef
MD5 059e48f5ef2086e1dd721b66690d99c7
BLAKE2b-256 3378860e032b97a46f6332f8c39f6b6a81a27cd0e95438c3cbf1f3489fc93ceb

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