Skip to main content

Celery-like task queue for ML inference.

Project description

ModelQ

ModelQ is a Python library designed specifically for scheduling and queuing machine learning inference tasks. It is built to be a more efficient alternative to existing task scheduling libraries, such as Celery, which may not always handle machine learning workloads effectively. ModelQ integrates Redis for backend data management, threading for concurrency, and uses task decorators to streamline the scheduling of tasks.

Features

  • ML-Specific Task Scheduling: Optimized to handle machine learning tasks, such as inferencing and model execution, with minimal overhead.
  • Redis-Based Queueing: Uses Redis for fast, reliable queuing and task storage, ensuring scalability and efficiency.
  • Lightweight Threading: Integrates Python threading for non-blocking operations and faster task execution.
  • Simple Task Decorators: Easily turn Python functions into scheduled tasks with decorators, making your code concise and readable.
  • Flexible Usage: Customize the queuing and scheduling mechanism to suit the requirements of different ML models or workflows.

Installation

To install ModelQ, you can use pip:

pip install modelq

Advanced Example

Here is a more advanced example demonstrating the use of ModelQ with retries, timeouts, and streaming tasks:

from modelq import ModelQ
import time
from modelq.exceptions import TaskTimeoutError

# Initialize ModelQ
q_instance = ModelQ()

print(q_instance)

# Define a streaming task with retries and a timeout
@q_instance.task(timeout=15, stream=True, retries=2)
def add_streaming(a, b, c):
    for i in range(1, 6):
        time.sleep(5)
        yield f"Intermediate result {i}: {a + b + c}"
    return a + b + c

# Define a regular task with retries
@q_instance.task(timeout=15, retries=3)
def add(a, b, c):
    return [a + b + c]

# Start workers
q_instance.start_workers()

try:
    # Testing regular task with retry mechanism
    result_add = add(3, 4, 5)
    print(f"Result of add(3, 4, 5): {result_add}")
    output = result_add.get_result(q_instance.redis_client)
    print(output)

    # Testing streaming task with retry mechanism
    result_add_streaming_task = add_streaming(1, 2, 3)
    output = result_add_streaming_task.get_stream(q_instance.redis_client)
    for result in output:
        print(result)
except TaskTimeoutError as e:
    print(f"Task timed out: {e}")

Configuration

ModelQ can be configured to connect to your Redis instance:

modelq = ModelQ(redis_host='your_redis_host', redis_port=your_redis_port, redis_db=0)

Roadmap

  • Support for GPU-based Tasks: Integrate GPU awareness to enable targeted execution on GPU-based machines.
  • Priority Queueing: Add priority levels to tasks to enable more urgent tasks to be executed sooner.
  • Fault Tolerance and Retries: Automatic retries for failed tasks to enhance robustness.

Contributing

We welcome contributions to ModelQ! If you have suggestions, feature requests, or bug reports, feel free to open an issue or submit a pull request on GitHub.

License

ModelQ is licensed under the MIT License. See LICENSE for more information.

Acknowledgements

  • Redis: Used for backend queuing and task management.
  • Celery: Inspiration for improving task management for machine learning-specific workloads.

Contact

If you have any questions or need help, feel free to contact us at [your_email@example.com].

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

modelq-0.1.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

modelq-0.1.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modelq-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.0 Linux/6.5.0-1025-azure

File hashes

Hashes for modelq-0.1.1.tar.gz
Algorithm Hash digest
SHA256 efd0cd0b05853e45d9578fe8b58856ffd0caaffc684f920a884b68a9fa57bf27
MD5 98e0e8936921a865b57688c6ce2b5d03
BLAKE2b-256 5095b52ca09bfdecbd80132c33a97c173b4eceda933def2561afe40fa96c3006

See more details on using hashes here.

File details

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

File metadata

  • Download URL: modelq-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.0 Linux/6.5.0-1025-azure

File hashes

Hashes for modelq-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 87bfbda8ffeb9dbacf6c2a284b640fbd6d3922b2cc036b40eb0400dc6070015e
MD5 dbf3405896bdee1a7174b04e1171c8e4
BLAKE2b-256 2d0c4bf5fa8171e3d1a82b55b90fcbff498f6c24917280505ad3b1a07df7b351

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