Skip to main content

Zaku Task Queue is for distributed ML-workloads.

Project description

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.

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

zaku-0.0.17.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

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

zaku-0.0.17-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file zaku-0.0.17.tar.gz.

File metadata

  • Download URL: zaku-0.0.17.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for zaku-0.0.17.tar.gz
Algorithm Hash digest
SHA256 1271e48696452f79b8bd9724a84159856db0114f6f75ddffb8aab8273b1a84a9
MD5 22f208510f7509dd26928e0cb0f9b5fe
BLAKE2b-256 e4e13ad067b6647a6b81a25781b5e2c8cf809719ac5526391c8ef4d4fdd050a3

See more details on using hashes here.

File details

Details for the file zaku-0.0.17-py3-none-any.whl.

File metadata

  • Download URL: zaku-0.0.17-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for zaku-0.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 4ab2d2d42df1872e45061bfe433886395b314c992aafcc31632cdc061a5021d2
MD5 565d25a253b955340c9611bb6d5a1975
BLAKE2b-256 1d90a9966e5ecef63ad0803294cd391660c1b2802e38fa50cb9e2996d821d7d0

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