Skip to main content

Add your description here

Project description

🚀 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! 🚀

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

flexify-0.1.0.tar.gz (70.8 kB view details)

Uploaded Source

Built Distribution

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

flexify-0.1.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file flexify-0.1.0.tar.gz.

File metadata

  • Download URL: flexify-0.1.0.tar.gz
  • Upload date:
  • Size: 70.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for flexify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 17efbb6c0a4ccae91e6fec212fcb78437346a597306fd4b21c77ad8cbc222444
MD5 3cb7e7e45508b2ca07023853076a7b20
BLAKE2b-256 8e71dee07dc5cdcb674de24f2b60efd58a6ba8d6c58004d5a3e71379fdd030da

See more details on using hashes here.

File details

Details for the file flexify-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: flexify-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for flexify-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1202fa87dd04616ddb0bb6c740ce7f72e825d7c284b78c1174ee87b817787faf
MD5 1261590287df8bc049819b8e2e1a5786
BLAKE2b-256 6a58b3738eb951b86c6d9bbb7dc51573b6375e0611bbd882a768804ef1f7f7ae

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