Skip to main content

A library for distributing computational workloads across multiple devices

Project description

PyPI Downloads Downloads License: MIT

Distributed Compute

A Python library for distributing computational workloads across multiple devices on a local network. Turn your spare laptops, desktops, and servers into a unified computing cluster with just a few commands.



Distributed Compute allows you to easily harness the power of multiple machines to process large workloads in parallel. Whether you're training ML models, processing data, or running simulations, this library makes distributed computing accessible without complex cluster management tools.

Features

  • Simple Setup - Get started with just 2 commands
  • Automatic Load Balancing - Tasks distributed to least-loaded workers
  • Fault Tolerance - Automatic task redistribution on worker failure
  • Real-time Monitoring - Beautiful CLI with live progress tracking
  • Clean API - Pythonic interface similar to multiprocessing.Pool
  • Plug & Play - No complex configuration required

Installation

Install via pip (Python 3.7+):

pip install distributed-compute-locally

Quick Start

1. Start the Coordinator

On your main machine:

distcompute coordinator

2. Connect Workers

On each worker machine (laptops, desktops, etc.):

distcompute worker <coordinator-ip>

Example:

distcompute worker 192.168.1.100

3. Run Your Computation

from distributed_compute import Coordinator

# Initialize coordinator
coordinator = Coordinator(port=5555)
coordinator.start()

# Define your compute function
def heavy_computation(x):
    return x ** 2

# Distribute work across all connected workers
results = coordinator.map(heavy_computation, range(1000))
print(results)  # [0, 1, 4, 9, 16, ...]

That's it! Your computation is now running across all connected machines.

Usage Examples

Running the Demo

See it in action with the built-in demo:

distcompute demo

This runs a Monte Carlo Pi estimation across 2 local workers with beautiful progress visualization.

Basic Usage

from distributed_compute import Coordinator

# Start coordinator
coordinator = Coordinator(port=5555)
coordinator.start()

# Simple map operation
def square(x):
    return x ** 2

results = coordinator.map(square, range(100))

ML Model Inference

from distributed_compute import Coordinator

coordinator = Coordinator(port=5555)
coordinator.start()

def predict(data_batch):
    # Your ML inference code
    return model.predict(data_batch)

# Distribute inference across workers
predictions = coordinator.map(predict, data_batches)

Data Processing Pipeline

from distributed_compute import Coordinator

coordinator = Coordinator(port=5555)
coordinator.start()

def process_file(filepath):
    # Your data processing logic
    data = load_file(filepath)
    result = transform(data)
    return result

# Process files in parallel
results = coordinator.map(process_file, file_list)

CLI Commands

The distcompute command provides several options:

# Start coordinator
distcompute coordinator [port]

# Connect worker
distcompute worker <host> [port] [name]

# Run demo
distcompute demo

Architecture

┌─────────────┐
│ Coordinator │ ← Main machine
└──────┬──────┘
       │
   ┌───┴────┬─────────┬─────────┐
   │        │         │         │
┌──▼──┐  ┌──▼──┐   ┌──▼──┐   ┌──▼──┐
│ W-1 │  │ W-2 │   │ W-3 │   │ W-4 │  ← Worker machines
└─────┘  └─────┘   └─────┘   └─────┘
  • Coordinator: Manages task distribution and collects results
  • Workers: Execute tasks and report back to coordinator
  • Load Balancing: Tasks assigned to least-loaded workers
  • Fault Tolerance: Failed tasks automatically redistributed

Advanced Configuration

Custom Port

coordinator = Coordinator(port=6000)

Verbose Logging

coordinator = Coordinator(port=5555, verbose=True)

Worker with Custom Name

distcompute worker 192.168.1.100 5555 my-worker-name

Requirements

  • Python 3.7 or higher
  • Network connectivity between machines
  • Same Python environment on all workers (recommended)

Examples

Check out the examples/ directory for more:

  • basic_usage.py - Simple distributed map example
  • ml_inference.py - ML model inference simulation
  • data_processing.py - Data processing pipeline
  • integration_test.py - Full end-to-end test

Troubleshooting

Workers not connecting?

  • Ensure port 5555 (default) is open on the coordinator machine
  • Check firewall settings
  • Verify machines are on the same network
  • Try specifying IP explicitly: distcompute worker 192.168.1.100

Tasks failing?

  • Ensure all workers have required dependencies installed
  • Check worker logs for error messages
  • Verify functions are serializable (no lambdas with external state)

Contributing

Contributions are welcome! This project aims to make distributed computing accessible to everyone.

License

MIT License - see LICENSE file for details.

Acknowledgments

Built to democratize distributed computing. Powered by Python's cloudpickle for seamless function serialization and psutil for resource monitoring.

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

distributed_compute_locally-0.1.1.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

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

distributed_compute_locally-0.1.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file distributed_compute_locally-0.1.1.tar.gz.

File metadata

File hashes

Hashes for distributed_compute_locally-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1923f0065d34ab6479ef858c436a57c5009fe469df92219985e4b058645c3330
MD5 ed5531c396a993a80b64ea5619f7e06d
BLAKE2b-256 f0851f1f9e721855aeaa6677d2095d6a9bd14fc647765d3a32ce9436eace287d

See more details on using hashes here.

File details

Details for the file distributed_compute_locally-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for distributed_compute_locally-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9e3664423e1d9c92acbd8132956b97093591df25fdaa6c11d0474107c613964
MD5 b2f32333cda53a8109ac682fba837cc3
BLAKE2b-256 8bdc35a6025ab092ee4ff01487f5ae049e145a620df7c67a3a450cda1d96337b

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