Skip to main content

Zaku, a fast Task Queue for ML Workloads

To get a quick overview of what you can do with zaku, check out the following:

Install zaku --- the latest version is {VERSION} on pypi.

pip install -U 'zaku[all]=={VERSION}'

Learning Usage Patterns by Running the Tests (specs)

Running tests is the best way to learn how to use a library. To run the tests in the ./specs folder, first download and setup redis-stack-server. Then start a zaku task queue server at local port 9000.

  1. install zaku and look at the options:
    pip install -U 'zaku[all]=={VERSION}'
    zaku -h
    
  2. install and run the redis-stack-server:
    brew install redis-stack-server
    redis-stack-server
    
  3. run the zaku task queue at port 9000:
    zaku --port 9000 --verbose
    

Now you can run the tests by running

make test

In pycharm, you should see the following:

Example Usage

Adding Jobs:

Supposed you have a TaskServer running at localhost:9000.

from zaku import TaskQ

queue = TaskQ(name="my-test-queue", uri="http://localhost:9000")

for i in range(100):
    queue.add_job({"job_id": i, "seed": i * 100})

Retrieving Jobs:

from zaku import TaskQ

queue = TaskQ(name="my-test-queue", uri="http://localhost:9000")

job_id, job = queue.take()

Now, after you have finished the job, you need to mark the job for completion. The way we do so is by calling

queue.mark_done(job_id)

Sometimes when you worker responsible for completeing the job encounters a failure, you need to also put the job back into the queue so that other workers can retry. You can do so by calling

queue.mark_reset()

Now, we offer a context manager TaskQ.pop, which automatically catches exceptions and resets the job (or marks it complete).

from zaku import TaskQ

queue = TaskQ(name="my-test-queue", uri="http://localhost:9000")

with queue.pop() as job:
  if job is None:
    print("No job available")
  
  print("Retrieved job:", job)

Developing Zaku (Optional)

First, git clone this repo, and install it in editable mode plus dependencies relevant for building the documentations:

git clone https://github.com/geyang/zaku.git
cd zaku
pip install -e '.[dev]'

Improving Documentation

We use sphinx to generate the documentation. To get started, make sure you install the dev dependencies. This should already be included if you installed zaku via the zaku[dev] flag. Take a look at ./docs/requirements.txt to see what packages are required for development.

When editing the documentation, you can use a preview server that automatically refreshes the browser upon changes in source. Simply do

make preview

Note: restarts are required, when the page index is changes. This includes adding and removing new pages.

To run the full build, call

make docs

License

Built with :heart: by @episodeyang. Distributed under the MIT license. See LICENSE for more information.

Metadata

Release files for zaku 0.0.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zaku 0.0.18
File Size Uploaded
zaku-0.0.18.tar.gz 20.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zaku 0.0.18
File Interpreter ABI Platform
zaku-0.0.18-py3-none-any.whl Python 3 none any Details

Total release size: 38.9 kB

Release files / zaku-0.0.18.tar.gz

Download URL zaku-0.0.18.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6c3829efca8098d15734318b53edc8ba3101fca040319e16db9e571e2a78e1c3
BLAKE2b-256 checksum
How to use checksums
46ece9bdbdae5036f76aa5909587068e065851698550cb23e4c1975b8e7232f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / zaku-0.0.18-py3-none-any.whl

Download URL zaku-0.0.18-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ba7198a4ad03282a038bbda38d4bc730e23c8bc21ed46e267863a12b8306e83
BLAKE2b-256 checksum
How to use checksums
68042e815bf4bf469183c89dbb490bd4d54ef6e51e06ac87a33abc1a298148ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page