Skip to main content

Python SDK for the Kailash container-node architecture

Project description

Kailash Python SDK

PyPI version Python versions Downloads MIT License Code style: black Tests: 751 passing Coverage: 100%

A Pythonic SDK for the Kailash container-node architecture

Build workflows that seamlessly integrate with Kailash's production environment while maintaining the flexibility to prototype quickly and iterate locally.


โœจ Highlights

  • ๐Ÿš€ Rapid Prototyping: Create and test workflows locally without containerization
  • ๐Ÿ—๏ธ Architecture-Aligned: Automatically ensures compliance with Kailash standards
  • ๐Ÿ”„ Seamless Handoff: Export prototypes directly to production-ready formats
  • ๐Ÿ“Š Real-time Monitoring: Live dashboards with WebSocket streaming and performance metrics
  • ๐Ÿงฉ Extensible: Easy to create custom nodes for domain-specific operations
  • โšก Fast Installation: Uses uv for lightning-fast Python package management
  • ๐Ÿค– AI-Powered: Complete LLM agents, embeddings, and hierarchical RAG architecture
  • ๐Ÿง  Retrieval-Augmented Generation: Full RAG pipeline with intelligent document processing
  • ๐ŸŒ REST API Wrapper: Expose any workflow as a production-ready API in 3 lines
  • ๐Ÿšช Multi-Workflow Gateway: Manage multiple workflows through unified API with MCP integration
  • ๐Ÿค– Self-Organizing Agents: Autonomous agent pools with intelligent team formation and convergence detection
  • ๐Ÿง  Agent-to-Agent Communication: Shared memory pools and intelligent caching for coordinated multi-agent systems
  • ๐Ÿ”’ Production Security: Comprehensive security framework with path traversal prevention, code sandboxing, and audit logging
  • ๐ŸŽจ Visual Workflow Builder: Kailash Workflow Studio - drag-and-drop interface for creating and managing workflows (coming soon)
  • ๐Ÿ” Cyclic Workflows (v0.2.0): Universal Hybrid Cyclic Graph Architecture with 30,000+ iterations/second performance
  • ๐Ÿ› ๏ธ Developer Tools: CycleAnalyzer, CycleDebugger, CycleProfiler for production-ready cyclic workflows
  • ๐Ÿ“ˆ High Performance: Optimized execution engine supporting 100,000+ iteration workflows
  • ๐Ÿ“ Enhanced Documentation (v0.2.2): Reorganized structure with production-ready workflow library

๐ŸŽฏ Who Is This For?

The Kailash Python SDK is designed for:

  • AI Business Coaches (ABCs) who need to prototype workflows quickly
  • Data Scientists building ML pipelines compatible with production infrastructure
  • Engineers who want to test Kailash workflows locally before deployment
  • Teams looking to standardize their workflow development process

๐Ÿš€ Quick Start

Installation

Requirements: Python 3.11 or higher

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# For users: Install from PyPI
pip install kailash

# For developers: Clone and sync
git clone https://github.com/integrum/kailash-python-sdk.git
cd kailash-python-sdk
uv sync

# Set up SDK development infrastructure (optional but recommended)
./scripts/setup-sdk-environment.sh

Your First Workflow

from kailash.workflow import Workflow
from kailash.nodes.data import CSVReaderNode
from kailash.nodes.code import PythonCodeNode
from kailash.runtime.local import LocalRuntime
import pandas as pd

# Create a workflow
workflow = Workflow("customer_analysis", name="customer_analysis")

# Add data reader
reader = CSVReaderNode(file_path="customers.csv")
workflow.add_node("read_customers", reader)

# Add custom processing using Python code
def analyze_customers(data):
    """Analyze customer data and compute metrics."""
    df = pd.DataFrame(data)
    # Convert total_spent to numeric
    df['total_spent'] = pd.to_numeric(df['total_spent'])
    return {
        "result": {
            "total_customers": len(df),
            "avg_spend": df["total_spent"].mean(),
            "top_customers": df.nlargest(10, "total_spent").to_dict("records")
        }
    }

processor = PythonCodeNode(code=analyze_customers)
workflow.add_node("analyze", processor)

# Connect nodes
workflow.connect("read_customers", "analyze", mapping={"data": "data"})

# Run locally
runtime = LocalRuntime()
results, run_id = runtime.execute(workflow, parameters={
    "read_customers": {"file_path": "customers.csv"}
})

print(f"Total customers: {results['analyze']['result']['total_customers']}")
print(f"Average spend: ${results['analyze']['result']['avg_spend']:.2f}")

Export to Production

# Export to Kailash container format
from kailash.utils.export import export_workflow

export_workflow(workflow, "customer_analysis.yaml")

๐Ÿ“š Documentation

For SDK Users

Build solutions with the SDK:

  • sdk-users/ - Everything you need to build with Kailash
    • developer/ - Node creation patterns and troubleshooting
    • workflows/ - Production-ready workflow library (NEW in v0.2.2)
      • Quick-start patterns (30-second workflows)
      • Industry-specific solutions (healthcare, finance)
      • Enterprise integration patterns
    • essentials/ - Quick reference and cheatsheets
    • nodes/ - Comprehensive node catalog (66+ nodes)
    • patterns/ - Architectural patterns

For SDK Contributors

Develop the SDK itself:

  • sdk-contributors/ - Internal SDK development resources
    • architecture/ - ADRs and design decisions
    • project/ - TODOs and development tracking
    • training/ - LLM training examples

Shared Resources

  • shared/ - Resources for both users and contributors
    • mistakes/ - Common error patterns and solutions
    • frontend/ - UI development resources

Quick Links

๐Ÿ”ฅ Advanced Features

Cyclic Workflows (Enhanced in v0.2.2)

Build iterative workflows with the new CycleBuilder API:

# Create an optimization cycle
workflow.create_cycle("optimization_loop")
    .connect("processor", "processor")
    .max_iterations(100)
    .converge_when("quality >= 0.95")
    .timeout(30)
    .build()

Self-Organizing Agent Pools

Create teams of AI agents that autonomously coordinate:

from kailash.nodes.ai import SelfOrganizingAgentPoolNode

agent_pool = SelfOrganizingAgentPoolNode(
    formation_strategy="capability_matching",
    convergence_strategy="quality_voting",
    min_agents=3,
    max_agents=10
)
workflow.add_node("agent_team", agent_pool)

Hierarchical RAG Pipeline

Build sophisticated document processing systems:

from kailash.nodes.data import DocumentSourceNode, HierarchicalChunkerNode
from kailash.nodes.ai import EmbeddingGeneratorNode

# Build a complete RAG pipeline
workflow.add_node("docs", DocumentSourceNode(directory="./knowledge"))
workflow.add_node("chunker", HierarchicalChunkerNode(chunk_size=512))
workflow.add_node("embedder", EmbeddingGeneratorNode(provider="openai"))

REST API Wrapper

Transform any workflow into a production API:

from kailash.api import WorkflowAPI

# Create API from workflow
api = WorkflowAPI(workflow, host="0.0.0.0", port=8000)
api.run()

# Your workflow is now available at:
# POST http://localhost:8000/execute
# GET http://localhost:8000/workflow/info

๐Ÿ—๏ธ Key Components

Nodes (60+ built-in)

  • Data: CSVReaderNode, JSONReaderNode, SQLDatabaseNode, DirectoryReaderNode
  • Transform: DataTransformer, DataFrameFilter, DataFrameJoiner
  • AI/ML: LLMAgentNode, EmbeddingGeneratorNode, A2ACoordinatorNode
  • API: RESTClientNode, GraphQLNode, AuthNode
  • Logic: SwitchNode, MergeNode, ConvergenceCheckerNode
  • Code: PythonCodeNode, WorkflowNode

Runtimes

  • LocalRuntime: Test workflows on your machine
  • DockerRuntime: Run in containers (coming soon)
  • ParallelRuntime: Execute nodes concurrently
  • CyclicWorkflowExecutor: Optimized for iterative workflows

Visualization

  • Mermaid diagrams: Workflow structure visualization
  • Real-time dashboard: Monitor execution with WebSocket streaming
  • Performance metrics: Track execution time, resource usage

๐Ÿงช Testing Your Workflows

# Use the testing runtime for unit tests
from kailash.runtime.testing import TestingRuntime

runtime = TestingRuntime()
runtime.set_mock_result("read_customers", {"data": test_data})
results, run_id = runtime.execute(workflow)
assert results["analyze"]["result"]["total_customers"] == len(test_data)

๐Ÿšข Production Deployment

  1. Export your workflow:

    export_workflow(workflow, "workflow.yaml", format="kailash")
    
  2. Deploy to Kailash:

    kailash deploy workflow.yaml --environment production
    
  3. Monitor in real-time:

    from kailash.visualization import DashboardServer
    
    server = DashboardServer(port=8080)
    server.start()
    # Open http://localhost:8080 for live monitoring
    

๐Ÿค Contributing

We welcome contributions! We use a Claude Code-driven workflow for all team collaboration.

๐Ÿš€ New Team Member?

Start Here โ†’ NEW_TEAM_MEMBER.md

For Contributors

Claude Code Workflow

All project management is done through conversational interaction with Claude Code:

  • No manual TODO editing - Claude Code handles all updates
  • No direct GitHub issues - Created through planning sessions
  • All progress tracked - Through natural conversation

See Contributing Guide for complete details.

Development Setup

# Clone the repository
git clone https://github.com/integrum/kailash-python-sdk.git
cd kailash-python-sdk

# Install with development dependencies
uv sync

# Run tests
pytest

# Run linting
black .
isort .
ruff check .

# Test all examples
python scripts/test-all-examples.py

๐Ÿ“ˆ Project Status

  • โœ… Core workflow engine
  • โœ… 60+ production-ready nodes
  • โœ… Local and parallel runtimes
  • โœ… Export to container format
  • โœ… Real-time monitoring
  • โœ… Comprehensive test suite (751 tests)
  • โœ… Self-organizing agent systems
  • โœ… Hierarchical RAG architecture
  • โœ… REST API wrapper
  • โœ… Cyclic workflow support with CycleBuilder API
  • โœ… Production security framework
  • โœ… Comprehensive workflow library (v0.2.2)
  • ๐Ÿšง Visual workflow builder (in progress)
  • ๐Ÿšง Docker runtime
  • ๐Ÿšง Cloud deployment tools

๐Ÿ“„ License

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

๐Ÿ™ Acknowledgments

Built with โค๏ธ by the Integrum team for the Kailash ecosystem.


Ready to build your first workflow? Check out our examples or dive into the documentation!

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kailash-0.3.0.tar.gz (485.5 kB view details)

Uploaded Source

Built Distribution

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

kailash-0.3.0-py3-none-any.whl (549.7 kB view details)

Uploaded Python 3

File details

Details for the file kailash-0.3.0.tar.gz.

File metadata

  • Download URL: kailash-0.3.0.tar.gz
  • Upload date:
  • Size: 485.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kailash-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2bbe06970f1aab8067e583cd4d57408f833edda8976666ca005aaeb67e0d8b93
MD5 44fa7f00c9c69f39a80de4f0cd131077
BLAKE2b-256 d6ebf7fccd3afc7105984119723430c3cf0465dc9af223a6caeb4e35e2ba9275

See more details on using hashes here.

File details

Details for the file kailash-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: kailash-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 549.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kailash-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef00f2354f2f286be357d101230b22d246ff5487230bf29f588803f86987d6b1
MD5 a8ff9a499e0b582fab4b138d7aa97ff9
BLAKE2b-256 2549cb9fe0650008ae86754d4a6c13a56527daecbb1eb8be1826a680577f31e9

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