Skip to main content

Add your description here

Project description

SmartPipeline 🚀

SmartPipeline is a robust, Pythonic framework for building modular computational workflows. It moves beyond simple DAGs (Directed Acyclic Graphs) by supporting automatic dependency injection, cyclic/iterative solving, and integrated caching, all while keeping your code clean and readable using standard Python type hints.

Whether you are running linear data processing or highly coupled Multidisciplinary Design Optimization (MDO) problems, SmartPipeline dynamically maps your functions and solves them efficiently.

🌟 Key Features

  • Type-Hint Driven Dependency Injection: No need to manually define edges. If Step B needs a variable x and Step A returns a variable named x, the pipeline connects them automatically.

  • We do the MDA, you do the MDO: We handle the heavy lifting of Multidisciplinary Analysis (MDA) — automatically isolating and converging feedback loops. Because our architecture is completely optimizer-agnostic, you can plug our dynamic evaluator into SciPy, OpenTURNS, PyOptSparse, or any algorithm you prefer.

  • Hybrid Solver: Automatically detects whether your pipeline is linear or contains feedback loops (cycles). It solves linear parts topologically and iterates over cyclic parts until convergence using Tarjan's Algorithm.

  • Modular Caching: Built-in decorators (@cached) to cache step results in RAM, HDF5 (for large arrays), or Pickle (for complex objects) with zero boilerplate.

  • Visualization: One-line generation of Graphviz diagrams (Flow charts or Data-Flow diagrams).

📦 Installation

We recommend using uv for lightning-fast installation, but standard pip works perfectly as well.

Using uv (Recommended):

uv pip install git+[https://github.com/wghami/SmartMDAO.git](https://github.com/wghami/SmartMDAO.git)

Using standard pip:

pip install git+[https://github.com/wghami/SmartMDAO.git](https://github.com/wghami/SmartMDAO.git)

Note: The visualization features require the graphviz system binary to be installed on your OS.

⚡ The Agnostic MDO Approach

SmartPipeline is built to let you define complex physics or engineering problems using pure, readable Python, without being locked into a specific optimization suite.

Here is how easily you can solve the classic Sellar coupled problem (a 2-discipline feedback loop) and optimize it using SciPy.

import math
from scipy.optimize import minimize
from smartmdao import Pipeline, HybridSolver
from smartmdao.optimization import PipelineEvaluator

# 1. We handle the heavy lifting: Multidisciplinary Analysis (MDA)
# The HybridSolver automatically detects the cyclic dependency between y1 and y2!
pipe = Pipeline(solver=HybridSolver())

@pipe.step(outputs=["y1"])
def discipline_1(z1: float, z2: float, x1: float, y2: float) -> float:
    return (z1 ** 2) + z2 + x1 - (0.2 * y2)

@pipe.step(outputs=["y2"])
def discipline_2(z1: float, z2: float, y1: float) -> float:
    return math.sqrt(abs(y1)) + z1 + z2

@pipe.step(outputs=["objective"])
def compute_objective(x1: float, z2: float, y1: float, y2: float) -> float:
    return (x1 ** 2) + z2 + (y1 ** 2) + math.exp(-y2)


# 2. You choose the optimizer: Agnostic Multidisciplinary Optimization (MDO)
# Map the optimizer's numeric array to our named design variables
evaluator = PipelineEvaluator(
    pipeline=pipe,
    design_vars=["z1", "z2", "x1"],
    constants={"y2": 1.0}  # Initial guess to kick off the cycle
)

# Pass the dynamically generated objective functions to ANY optimizer (SciPy, OpenTURNS, etc.)
result = minimize(
    evaluator.get_objective("objective"), 
    x0=[1.0, 1.0, 1.0], 
    method='SLSQP', 
    bounds=[(-10.0, 10.0), (0.0, 10.0), (0.0, 10.0)]
)

print(f"Optimization Success! Objective: {result.fun:.4f}")

The user retains full control over the Pythonic equations, while the PipelineEvaluator caches the complex cyclic MDA evaluations so the optimizer can request objectives and constraints independently without performance penalties.

🛠️ Architecture Overview

  • core.py: The entry point. Manages steps and delegates execution to solvers.

  • solvers.py: The brains.

    • DAGSolver: For standard linear pipelines.

    • IterativeSolver: For fixed-point iteration problems.

    • HybridSolver: Uses Tarjan's Algorithm to decompose graphs into linear and cyclic components dynamically.

  • optimization.py: Contains the stateful PipelineEvaluator bridge, providing callable factories for external optimizers.

  • executor.py: Handles argument binding and runtime memory management.

  • visualization.py: Generates high-quality PDF/PNG diagrams of your workflow.

🚀 Future Improvements & Roadmap

To make SmartPipeline even better, the following improvements are planned:

  • Parallel Execution: Integrating asyncio or ProcessPoolExecutor to allow independent branches of the DAG to run in parallel.

  • Pydantic Integration: Replace standard dataclasses with Pydantic models for robust runtime data validation and schema generation.

  • Checkpointing: Allow the pipeline to pause and resume from a specific state in case of failure, serializing the entire memory dictionary.

  • Web UI: A lightweight Flask/Streamlit dashboard to visualize pipeline progress and convergence plots in real-time.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

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

smartmdao-1.1.0.tar.gz (213.2 kB view details)

Uploaded Source

Built Distribution

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

smartmdao-1.1.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file smartmdao-1.1.0.tar.gz.

File metadata

  • Download URL: smartmdao-1.1.0.tar.gz
  • Upload date:
  • Size: 213.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"20.04","id":"focal","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for smartmdao-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9e98280b1e67f390656d72f0e846c611ab2d2d2656a6423e878cb952b6bb3975
MD5 552d1115d4a5e1c33482bc6775707311
BLAKE2b-256 a645ec93b21abe2df51c517d019cc2b05b1833cebaf8b0b4c46b6668af66899a

See more details on using hashes here.

File details

Details for the file smartmdao-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: smartmdao-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"20.04","id":"focal","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for smartmdao-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa530d9ce25ffc4a503f636971fa2c89e68a2789dfac1976326f5c36f69a3dba
MD5 6760d6deea09363fb177387ccd71f4df
BLAKE2b-256 9c5174477c07e1c8dc558c733d8f115d1f77566e7cfaab9b36bf63ced0db2bd3

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