Skip to main content

No project description provided

Project description

ipydagflow

Interactive DAG (Directed Acyclic Graph) visualization widgets for Jupyter notebooks using React Flow.

Features

  • ๐ŸŽจ Beautiful Interactive Visualizations - Smooth, modern DAG rendering with React Flow
  • ๐Ÿ”ง Two APIs - Low-level (DynamicDAG) and high-level (StepDAG) interfaces
  • ๐ŸŽฏ Automatic Layout - No need to specify positions - nodes are laid out automatically
  • ๐ŸŽจ Customizable Styles - Full control over colors, borders, and appearance
  • ๐Ÿ“Š Built for Data Pipelines - Perfect for ETL workflows, ML pipelines, and task dependencies
  • โœ… Validation - Automatic cycle detection and DAG validation
  • ๐Ÿ” Interactive - Click nodes to see details, drag to rearrange

Installation

pip install ipydagflow

For development:

git clone https://github.com/yourusername/ipydagflow
cd ipydagflow
pip install -e .

Quick Start

High-Level API (StepDAG)

Build DAGs programmatically using Step objects:

from ipydagflow import StepDAG, Step

# Create steps
extract = Step(id="extract", label="Extract Data", step_type="datasource")
transform = Step(id="transform", label="Transform", step_type="box")
load = Step(id="load", label="Load to DB", step_type="datasource")

# Connect steps
extract.add_child(transform)
transform.add_child(load)

# Create and display DAG
dag = StepDAG()
dag.add_steps(extract, transform, load)
dag.render()  # Returns a widget to display in Jupyter

Low-Level API (DynamicDAG)

For direct control over nodes and edges:

from ipydagflow import DynamicDAG

nodes = [
    {"id": "1", "type": "datasource", "data": {"label": "Input"}},
    {"id": "2", "type": "box", "data": {"label": "Process"}},
    {"id": "3", "type": "datasource", "data": {"label": "Output"}},
]

edges = [
    {"id": "e1", "source": "1", "target": "2"},
    {"id": "e2", "source": "2", "target": "3"},
]

dag = DynamicDAG(nodes=nodes, edges=edges)
dag  # Display in Jupyter

Examples

Complex Pipeline

from ipydagflow import StepDAG, Step

# Build a data processing pipeline
raw = Step(id="raw", label="Raw Data", step_type="datasource")
clean = Step(id="clean", label="Clean", step_type="box")
feature_a = Step(id="feat_a", label="Feature A", step_type="box")
feature_b = Step(id="feat_b", label="Feature B", step_type="box")
combine = Step(id="combine", label="Combine", step_type="box")
output = Step(id="output", label="Output", step_type="datasource")

# Connect: raw -> clean -> [feature_a, feature_b] -> combine -> output
raw.add_child(clean)
clean.add_children(feature_a, feature_b)
feature_a.add_child(combine)
feature_b.add_child(combine)
combine.add_child(output)

# Render
dag = StepDAG()
dag.add_steps(raw, clean, feature_a, feature_b, combine, output)
dag.render()

Custom Styling

custom_styles = {
    "datasource": {
        "background": "rgba(255, 99, 132, 0.8)",
        "color": "white",
        "borderColor": "#ff6384",
        "borderWidth": 3,
    },
    "box": {
        "background": "rgba(54, 162, 235, 0.8)",
        "color": "white",
        "borderColor": "#36a2eb",
        "borderWidth": 2,
    },
}

dag = StepDAG(styles=custom_styles)
dag.add_steps(step1, step2, step3)
dag.render()

Adding Metadata

step = Step(
    id="process",
    label="Calculate Metrics",
    step_type="box",
    data={
        "owner": "data-team",
        "schedule": "0 0 * * *",
        "retry": 3,
        "timeout": "1h"
    }
)
# Click the node in the widget to see the metadata!

API Reference

Step

Step(
    id: str,              # Unique identifier
    label: str,           # Display label
    step_type: str,       # Node type: "datasource", "box", or custom
    data: dict            # Additional metadata
)

Methods:

  • add_child(step) - Add a child step
  • add_children(*steps) - Add multiple children
  • add_parent(step) - Add a parent step
  • get_all_descendants() - Get all descendant steps
  • get_all_ancestors() - Get all ancestor steps

StepDAG

StepDAG(styles: dict = None)

Methods:

  • add_step(step) - Add a step
  • add_steps(*steps) - Add multiple steps
  • get_step(step_id) - Get step by ID
  • get_all_steps() - Get all steps
  • get_root_steps() - Get steps with no parents
  • get_leaf_steps() - Get steps with no children
  • validate() - Validate DAG (returns list of errors)
  • render() - Create and return DynamicDAG widget

DynamicDAG

DynamicDAG(
    nodes: list,          # List of node dicts
    edges: list,          # List of edge dicts
    styles: dict = None   # Custom styling
)

Node format:

{
    "id": "unique_id",
    "type": "datasource",  # or "box"
    "data": {"label": "Display Name", ...},
    "position": {"x": 100, "y": 100}  # Optional - auto-layout if omitted
}

Edge format:

{
    "id": "edge_id",
    "source": "source_node_id",
    "target": "target_node_id",
    "animated": True  # Optional
}

Development

Setup

# Clone the repo
git clone https://github.com/yourusername/ipydagflow
cd ipydagflow

# Install dependencies
npm install
pip install -e .

# Build JavaScript
npm run build

# Run in dev mode (auto-rebuild on changes)
npm run dev

Project Structure

ipydagflow/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ ipydagflow/
โ”‚       โ”œโ”€โ”€ __init__.py           # Main exports
โ”‚       โ”œโ”€โ”€ widgets/              # Widget classes
โ”‚       โ”‚   โ”œโ”€โ”€ dynamic_dag.py    # Low-level widget
โ”‚       โ”‚   โ””โ”€โ”€ step_dag.py       # High-level builder
โ”‚       โ”œโ”€โ”€ models/               # Data models
โ”‚       โ”‚   โ””โ”€โ”€ step.py           # Step class
โ”‚       โ”œโ”€โ”€ utils/                # Utilities
โ”‚       โ”‚   โ””โ”€โ”€ layout.py         # Layout algorithms
โ”‚       โ””โ”€โ”€ static/               # Built JS/CSS
โ”œโ”€โ”€ ui/                           # TypeScript/React source
โ”‚   โ”œโ”€โ”€ dynamic_dag.tsx          # React Flow component
โ”‚   โ””โ”€โ”€ dynamic_dag.css          # Styles
โ””โ”€โ”€ examples/                     # Example notebooks

License

MIT

Contributing

Contributions welcome! Please open an issue or PR on GitHub.

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

ipydagflow-0.0.4.tar.gz (153.8 kB view details)

Uploaded Source

Built Distribution

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

ipydagflow-0.0.4-py3-none-any.whl (149.1 kB view details)

Uploaded Python 3

File details

Details for the file ipydagflow-0.0.4.tar.gz.

File metadata

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

File hashes

Hashes for ipydagflow-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2ac66042130dd10193ec17e837397dafd132c1f2ec477991d4caef1d4077c616
MD5 2c4ecc73290f80920e70911fd995cdba
BLAKE2b-256 74e616d706e1bd5d9b00f01c27585770914678139564c17c4df99d5d62e975a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipydagflow-0.0.4.tar.gz:

Publisher: publish.yml on Vanessamae23/ipydagflow

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

File details

Details for the file ipydagflow-0.0.4-py3-none-any.whl.

File metadata

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

File hashes

Hashes for ipydagflow-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c93a88ae6e53cc922ad96e8006b06bd5f337fbe557064ec628fc53e82cbeda8e
MD5 2b836fa6c34446bfdfc9125dd2168840
BLAKE2b-256 cc77813c46bd958a3bd91aaa61ce979531ab749223d617bb97c0591d033d7a9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipydagflow-0.0.4-py3-none-any.whl:

Publisher: publish.yml on Vanessamae23/ipydagflow

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