Skip to main content

A declarative, extensible framework for building smart data pipelines in Python

Project description

aptdata

v0.0.2 · A declarative, extensible framework for building smart data pipelines in Python.

Python License Version


Overview

aptdata is built around three universal abstractions — System, Flow, and Component — that cover every data-processing paradigm in a single, coherent model:

flowchart TD
    I["IComponent / IFlow / ISystem\n@dataclass + ABC — pure interfaces"]
    B["BaseComponent / BaseFlow / BaseSystem\n@pydantic_dataclass — validated fields"]
    Y["Your concrete implementations"]

    I --> B --> Y

Datasets remain the fundamental data-exchange contract (IDataset / BaseDataset). Every outcome from the CLI is emitted as a machine-readable JSON line, making aptdata a natural fit for AI orchestrators, CI/CD pipelines and scripted workflows.


Requirements

  • Python ≥ 3.10
  • Poetry (for development)

Installation

From PyPI

pip install aptdata

Optional extras

pip install aptdata[pandas]   # pandas support
pip install aptdata[spark]    # PySpark support
pip install aptdata[plugins]  # REST, PostgreSQL, Parquet I/O
pip install aptdata[ai]       # MCP server for AI agents
pip install aptdata[all]      # everything

From source (development)

git clone https://github.com/strondata/smart-data.git
cd aptdata
poetry install

Quick start

from pydantic.dataclasses import dataclass as pydantic_dataclass
from aptdata.core import (
    BaseDataset, IDataset,
    BaseComponent, ComponentMeta, ComponentKind,
    BaseFlow, IFlow,
    BaseSystem,
)

@pydantic_dataclass
class MemoryDataset(BaseDataset):
    def __post_init__(self): self._data = None
    def read(self): return self._data
    def write(self, data): self._data = data

@pydantic_dataclass
class DoubleComponent(BaseComponent):
    def validate_inputs(self, inputs: list[IDataset]) -> bool:
        return len(inputs) == 1
    def execute(self, inputs: list[IDataset]) -> list[IDataset]:
        out = MemoryDataset(uri="memory://out")
        out.write([x * 2 for x in inputs[0].read()])
        return [out]

@pydantic_dataclass
class ETLFlow(BaseFlow):
    def __post_init__(self):
        self._nodes = {}
        self._edges = []
        self._compiled = False
    def add_component(self, c): self._nodes[c.component_id] = c
    def connect(self, src, tgt, condition=None): ...
    def compile(self): self._compiled = True
    def run(self, inputs): return inputs  # wire your logic here

@pydantic_dataclass
class MySystem(BaseSystem):
    def __post_init__(self): self._flows: list[IFlow] = []
    def register_flow(self, flow): self._flows.append(flow)
    def run(self):
        for flow in self._flows:
            flow.run([])

# Register and run via CLI
from aptdata.plugins import registry
registry.register("my_system", MySystem)
aptdata run my_system
# {"event": "pipeline.started", "pipeline": "my_system", "env": "dev", "dry_run": false, "trace_id": null}
# {"event": "pipeline.completed", "pipeline": "my_system", "env": "dev", "dry_run": false, "elapsed_seconds": 0.001, "trace_id": null}

CLI reference

aptdata run SYSTEM_NAME [--env ENV] [--dry-run]
aptdata monitor [--refresh SECONDS]
aptdata scaffold PROJECT_NAME [--template TEMPLATE] [--output PATH]
aptdata schema export --output schema.json
aptdata system list [--json]
aptdata system info NAME [--json]
aptdata system validate NAME
aptdata plugin list [--json]
aptdata plugin inspect NAME [--json]
aptdata plugin preview READER [--limit N]
aptdata plugin load MODULE_PATH
aptdata config validate PATH
aptdata config init [--output PATH]
aptdata config show PATH
aptdata config run PATH [--env ENV]
aptdata telemetry status [--json]
aptdata telemetry export [--format json]
aptdata mesh list [--dir DIR] [--json]
aptdata mesh run COMPONENT [--dir DIR] [--dry-run] [--json]
aptdata mesh build COMPONENT [--dir DIR] [--json]
aptdata mcp-start [--transport TRANSPORT]
aptdata interactive

Every static command supports --json for machine-readable JSON line output (backward compatible). Without --json, commands render Rich tables, panels, and syntax-highlighted output.

Scaffold templates

Template Description
hello-world Minimal pandas pipeline (default)
medallion Bronze → Silver → Gold data lakehouse
rag-ingestion RAG pipeline: extract → chunk → embed → load
data-quality-test Schema contract + expectation suite
job-wheel Python wheel executor for portable job packaging
docker-compose-app Multi-service Docker Compose application
aptdata scaffold my_lakehouse --template medallion
aptdata scaffold my_job --template job-wheel
aptdata scaffold my_service --template docker-compose-app

Processing Engines

Engine-agnostic transformation wrappers for pandas and PySpark:

from aptdata.plugins.transform import PandasTransformer

def clean(df):
    return df.dropna().drop_duplicates()

transformer = PandasTransformer("clean", clean)
result = transformer.transform(my_dataset)

See Transform Engines docs for PySpark usage.


Data Quality & Contracts

from aptdata.plugins.quality import (
    EnforcementMode, ExpectColumnToNotBeNull,
    QualityValidator, SchemaContract,
)

validator = QualityValidator(
    expectations=[ExpectColumnToNotBeNull("id")],
    enforcement=EnforcementMode.ABORT,
)
clean_data = validator.validate(raw_df)

See Quality docs for all built-in expectations.


Data Governance

from aptdata.plugins.governance import (
    BusinessRule, DatasetCatalog, DatasetCatalogEntry, LineageStore,
)
from aptdata.core.lineage import LineageGraph, LineageNode, LineageEventType

# Lineage tracking
graph = LineageGraph(run_id="run-1", workflow_name="etl")
graph.add_node(LineageNode(dataset_uri="s3://raw/data", event_type=LineageEventType.READ))

store = LineageStore()
store.save(graph)

See Governance docs for the full API.


AI Agents & MCP Server

aptdata ships with a built-in Model Context Protocol server (mcp-start). This transforms AI assistants (like Claude, Copilot, or Devin) into autonomous data engineers with direct access to:

  • Pipeline Execution: Trigger and monitor data flows (run_flow).
  • Data Quality: Audit the latest quality test results (quality://reports/...).
  • Data Governance: Read business rules to prevent violations (governance://rules).
  • Lineage: Trace upstream dependencies and column-level provenance (get_pipeline_lineage).
aptdata mcp-start --transport stdio

See the MCP Documentation for setup instructions.


Release process

Releases are automated via the Release workflow. After a PR is merged into main, the CI reads its labels and bumps the version accordingly.

Label Effect
release:patch 0.0.1 → 0.0.2
release:minor 0.0.1 → 0.1.0
release:major 0.0.1 → 1.0.0
release:skip no release (explicit opt-out)
(no label) no release (silent skip)

The workflow will:

  1. Detect the merged PR and its labels.
  2. Run bump-my-version bump <part> to update pyproject.toml and aptdata/__init__.py.
  3. Create a chore(release): bump version to X.Y.Z commit and a vX.Y.Z tag.
  4. Push the commit and tag to main.
  5. The tag push automatically triggers the Publish to PyPI workflow.

Branch protection note: GitHub Actions must have read and write permissions (Settings → Actions → General → Workflow permissions) and, if branch protection is enabled on main, the rule must allow GitHub Actions to bypass it.


Development

make install   # install all dependencies
make test      # run the test suite
make lint      # lint with ruff
make docs      # build the documentation

Documentation

Full documentation is available in the docs/ directory and can be served locally with:

mkdocs serve

License

MIT

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

aptdata-0.0.3.tar.gz (69.2 kB view details)

Uploaded Source

Built Distribution

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

aptdata-0.0.3-py3-none-any.whl (94.5 kB view details)

Uploaded Python 3

File details

Details for the file aptdata-0.0.3.tar.gz.

File metadata

  • Download URL: aptdata-0.0.3.tar.gz
  • Upload date:
  • Size: 69.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aptdata-0.0.3.tar.gz
Algorithm Hash digest
SHA256 dbb022dc722dfc5febddf8b37f974feefc6ace6a751ddd8fe243d44323486beb
MD5 9c52c5cd40e83be47d00e17bec71b717
BLAKE2b-256 86e748a69d9778fed924f69ce4b96db11a11fb8542205caeb982d13e54fe42bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for aptdata-0.0.3.tar.gz:

Publisher: publisher.yml on strondata/smart-data

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aptdata-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: aptdata-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 94.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aptdata-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bbcc9f8d58530c895f4d8e21fcf7d6fd6b3889ab861387340dd1d8c4870da24c
MD5 95cdd77f45019099fbc7c7eb03733437
BLAKE2b-256 effdb8e015d52b412d01e66f7917db3ec1b1ae588d8e49f98947ca32b5e4ca66

See more details on using hashes here.

Provenance

The following attestation bundles were made for aptdata-0.0.3-py3-none-any.whl:

Publisher: publisher.yml on strondata/smart-data

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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