Skip to main content

Basic Usage

python

CLI Usage

You can interact with ModelQ using the modelq command-line tool. All commands require an --app-path parameter to locate your ModelQ instance in module:object format.

Start Workers

Start background worker threads for executing tasks.

Check Queue Status

Show number of servers, queued tasks, and registered task types.

List Queued Tasks

Display a list of all currently queued task IDs and their names.

Clear the Queue

Remove all tasks from the queue.

Remove a Specific Task

Remove a specific task from the queue by ID.

Serve API

Start a FastAPI server for ModelQ to accept task submissions over HTTP.

Version

Print the current version of ModelQ CLI.

Pydantic Support

ModelQ supports Pydantic models as both input and output types for tasks. This allows automatic validation of input parameters and structured return values.

Example

python

Getting Result

python
ModelQ will validate inputs using Pydantic and serialize/deserialize results seamlessly.

Middleware Support

ModelQ allows you to plug in custom middleware to hook into events:

Supported Events

  • before_worker_boot
  • after_worker_boot
  • before_worker_shutdown
  • after_worker_shutdown
  • before_enqueue
  • after_enqueue
  • on_error

Example

python

Attach to ModelQ instance:

python

Configuration

Connect to Redis using custom config:
python

License

ModelQ is released under the MIT License.

Contributing

We welcome contributions! Open an issue or submit a PR at github.com/modelslab/modelq.