examples

Taskinity Examples

This directory contains various examples demonstrating how to use Taskinity in different scenarios. Each example is self-contained and includes all necessary files to run it, including Dockerfiles and docker-compose configurations where appropriate.

Taskinity Project Structure

The Taskinity project has been reorganized into a more modular structure:

  1. Core Module (taskinity/core/): Contains essential functionality including task and flow decorators, DSL parser and executor, and flow management utilities.

  2. Extensions Module (taskinity/extensions/): Contains additional features like visualization tools, code converters, data processors, and API clients.

  3. Utils Module (taskinity/utils/): Provides supporting functionality like environment variable management, benchmarking tools, and logging utilities.

All examples in this directory have been updated to use the new module structure. The old flow_dsl module references have been replaced with the new taskinity_core module.

Examples Overview

1. Email Processing

A complete example of using Taskinity to process emails. This example demonstrates how to:

Directory: email_processing

2. Data Processing

Examples of data processing pipelines using Taskinity. These examples show how to:

Directory: data_processing

3. API Integration

Examples of integrating external APIs with Taskinity. These examples demonstrate:

Directory: api_integration

4. Visualization

Examples of visualizing Taskinity flows. These examples show how to:

Directory: visualization

5. Parallel Tasks

Examples of running tasks in parallel with Taskinity. These examples demonstrate:

Directory: parallel_tasks

Running the Examples

Using the Makefile

This directory includes a centralized Makefile that allows you to run all examples and tests from one place. The Makefile is compatible with the new modular Taskinity structure (core, extensions, utils).

View Available Commands

# Show all available commands
make help

Running Examples

# Run all examples
make run-all

# Run a specific example
make email-run     # Run email processing example
make data-run      # Run data processing example
make api-run       # Run API integration example
make parallel-run  # Run parallel tasks example
make viz-run       # Run visualization example
make perf-run      # Run performance benchmarks

Running Tests

# Run all tests
make test-all

# Run tests for a specific example
make email-test    # Run email processing tests
make data-test     # Run data processing tests
make api-test      # Run API integration tests
make parallel-test # Run parallel tasks tests
make viz-test      # Run visualization tests
make perf-test     # Run performance benchmark tests

Docker Environment Management

# Start Docker environments
make email-docker-basic    # Start basic email Docker environment
make email-docker-mock     # Start mock email Docker environment with MailHog
make email-docker-full     # Start full email Docker environment

# Stop Docker environments
make email-docker-down     # Stop all email Docker environments

# Start all Docker environments
make docker-up-all

# Stop all Docker environments
make docker-down-all

Manual Execution

Each example directory also contains a README.md file with specific instructions for running that example manually. In general, you can follow these steps:

  1. Navigate to the example directory:
    cd examples/[example_name]
    
  2. Copy the .env.example file to .env and configure it:
    cp .env.example .env
    # Edit .env with your specific configuration
    
  3. If the example includes a docker-compose.yml file, start the required services:
    docker-compose up -d
    

    Or use the provided shell scripts for Docker environments (in email_processing):

    ./docker-up.sh [basic|mock|full]    # Start a specific Docker environment
    ./docker-down.sh [basic|mock|full]   # Stop a specific Docker environment
    
  4. Run the example:
    python main.py
    

Performance Comparisons

Where applicable, examples include performance comparisons with other solutions to demonstrate Taskinity’s efficiency. These comparisons typically measure:

Contributing

Feel free to contribute your own examples by creating a pull request. Please follow these guidelines: