Skip to main content

🚀 Flexify

Python Version License Coverage

Flexify is a lightweight, modular task processing framework for Python that makes it incredibly easy to build and execute workflows! 🎯

✨ Why Flexify?

Do you find yourself:

  • 😩 Writing the same processing patterns over and over?
  • 🔧 Hard-coding workflows that are difficult to modify?
  • 📊 Struggling to visualize and track complex data pipelines?
  • 🏗️ Dealing with heavyweight workflow engines that are overkill for your needs?

Flexify makes it simple! Define reusable modules, describe your workflow in YAML or JSON, and let Flexify handle the rest!

🎯 Key Features

  • 🧩 Modular Design: Create reusable processing modules that can be combined in any way
  • 📝 Simple Configuration: Define workflows in human-readable YAML or JSON files
  • 🔄 Flexible Data Flow: Easy parameter mapping between modules
  • 📊 Status Tracking: Monitor workflow execution and module status in real-time
  • 🐍 Pure Python: No complex dependencies or external services required
  • 🧪 Well-Tested: 97% test coverage with comprehensive test suite
  • 📚 Rich Examples: Ready-to-use example modules for text processing and math operations

🚀 Quick Start

Installation

pip install flexify

Create Your First Module

from typing import Dict, Any, List
from flexify.core import Module, ParamInfo

class GreetingModule(Module):
    """A simple module that creates greetings."""
    
    def execute(self, session: Dict[str, Any]) -> Dict[str, Any]:
        name = session.get("name", "World")
        greeting = f"Hello, {name}!"
        session["greeting"] = greeting
        return session
    
    @classmethod
    def get_param_info(cls) -> List[ParamInfo]:
        return [
            ParamInfo(name="name", type=str, required=False, default="World"),
            ParamInfo(name="greeting", type=str, required=False, default="")
        ]

Define a Workflow

Create a workflow file greeting_workflow.yaml:

name: greeting_workflow
version: 1.0.0

modules:
  - name: greet_step
    class_name: your_module.GreetingModule
    params:
      name: "Flexify User"

Run Your Workflow

from flexify.runner import SimpleRunner

runner = SimpleRunner()
result = runner.run("greeting_workflow.yaml")
print(result["greeting"])  # Output: Hello, Flexify User!

📖 Documentation

Module Development

Modules are the building blocks of Flexify workflows. Each module:

  • Inherits from the Module base class
  • Implements an execute() method that processes data
  • Defines parameters using get_param_info()
  • Maintains its execution status

Workflow Configuration

Workflows can be defined in YAML or JSON with:

  • name: Workflow identifier
  • modules: List of modules to execute in sequence
  • initial_session: Starting data for the workflow

Advanced Features

  • Parameter Mapping: Route data between modules using input/output mappings
  • Module Registry: Dynamically discover and load modules
  • Error Handling: Comprehensive error tracking and reporting
  • Status Monitoring: Real-time workflow execution status

Error Handling

Flexify provides comprehensive error handling through the FlexifyException exception:

try:
    runner = SimpleRunner()
    result = runner.run("workflow.yaml")
except FlexifyException as e:
    print(f"Error: {e}")                    # [ModuleName] Error message
    print(f"Failed module: {e.module_name}") # ModuleName
    if e.original_error:
        print(f"Original error: {e.original_error}")

Common error scenarios:

  • Missing required parameters: Required input 'param_name' not found
  • Invalid parameter types: Input 'param_name' has invalid type
  • Module execution failures: Captures and wraps any exceptions during execution
  • Import errors: When specified module classes cannot be found

Module Discovery

Modules are loaded dynamically using their full class path:

modules:
  - name: calculator
    class_name: "flexify.examples.math_modules.CalculatorModule"

The ModuleRegistry.get_or_import() method handles:

  • Dynamic importing of module classes
  • Validation that classes inherit from Module
  • Caching of loaded modules for performance

🛠️ Built-in Modules

Core Control Flow Modules

  • LoopModule: Iterate over arrays and execute sub-workflows for each element
  • CaseModule: Execute different workflows based on condition matching

Text Processing Modules

  • TextReaderModule: Read text files
  • TextTransformModule: Transform text (upper, lower, title, reverse)
  • WordCountModule: Calculate text statistics

Math Operations Modules

  • CalculatorModule: Basic arithmetic operations
  • StatisticsModule: Calculate statistical measures
  • FibonacciModule: Generate Fibonacci sequences

Control Flow Examples

Loop Module

modules:
  - name: process_array
    class_name: flexify.core.LoopModule
    params:
      workflow:
        modules:
          - name: square
            class_name: flexify.examples.math_modules.CalculatorModule
            params: {operation: multiply}
            inputs: {a: item, b: item}
    inputs:
      array: numbers

Case Module

modules:
  - name: process_by_type
    class_name: flexify.core.CaseModule
    params:
      cases:
        add:
          modules: [{name: add_op, class_name: ..., params: {operation: add}}]
        multiply:
          modules: [{name: mult_op, class_name: ..., params: {operation: multiply}}]
    inputs:
      value: operation_type

💻 System Requirements

  • Python: 3.10 or higher
  • Dependencies: PyYAML for YAML support
  • OS: Windows, macOS, Linux

🤝 Contributing

We welcome contributions! Please feel free to submit issues, fork the repository, and create pull requests.

📄 License

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

🙏 Acknowledgments

Built with ❤️ using modern Python best practices and clean architecture principles.


Ready to make your workflows flexible? Get started with Flexify today! 🚀

Release files for flexify 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flexify 0.1.0
File Size Uploaded
flexify-0.1.0.tar.gz 70.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flexify 0.1.0
File Interpreter ABI Platform
flexify-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 92.8 kB

Release files / flexify-0.1.0.tar.gz

Download URL flexify-0.1.0.tar.gz
Size 70.8 kB
Tags Source
SHA-256 checksum
How to use checksums
17efbb6c0a4ccae91e6fec212fcb78437346a597306fd4b21c77ad8cbc222444
BLAKE2b-256 checksum
How to use checksums
8e71dee07dc5cdcb674de24f2b60efd58a6ba8d6c58004d5a3e71379fdd030da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release files / flexify-0.1.0-py3-none-any.whl

Download URL flexify-0.1.0-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1202fa87dd04616ddb0bb6c740ce7f72e825d7c284b78c1174ee87b817787faf
BLAKE2b-256 checksum
How to use checksums
6a58b3738eb951b86c6d9bbb7dc51573b6375e0611bbd882a768804ef1f7f7ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page