-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
132 lines (77 loc) · 2.93 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
Zaku, a fast Task Queue for ML Workloads
========================================
To get a quick overview of what you can do with ``zaku``, check out the
following:
- take a look at the basic tutorial or the tutorial for robotics:
- `Zaku Basics <tutorials/basics>`__
- or try to take a look at the example gallery
`here <examples/01_simple_queue>`__
Install zaku — the latest version is ``{VERSION}`` on
`pypi <https://pypi.org/project/zaku/%7BVERSION%7D/>`__.
.. code-block:: python
pip install -U 'zaku[all]=={VERSION}'
**Setting Up Zaku Server**
The server script is installed as the command ``zaku``. First, take a
look at its options by running
.. code-block:: shell
zaku -h
This should show you the documents on all of the arguments. Now, to
setup a zaku task queue server, run the following: This enables access
from other than localhost.
.. code-block:: shell
zaku --host 0.0.0.0 --port 9000
**Adding Jobs**:
Supposed you have a TaskServer running at ``localhost:9000``.
.. code-block:: python
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**:
.. code-block:: python
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
.. code-block:: python
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
.. code-block:: python
queue.mark_reset()
Now, we offer a context manager ``TaskQ.pop``, which automatically
catches exceptions and resets the job (or marks it complete).
.. code-block:: python
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)
--------------------------
If you want to develop zaku, you can install it in editable mode plus
dependencies relevant for building the documentations:
.. code-block:: shell
cd zaku
pip install -e '.[dev]'
To build the documentations, run
.. code-block:: shell
make docs
Running the tests (specs)
~~~~~~~~~~~~~~~~~~~~~~~~~
To run the tests in the spec folder, first start a zaku task queue
server at local port ``9000``, with a redis-stack-server in the backing.
1. run the ``redis-stack-server``: ``shell redis-stack-server``
2. run the zaku task queue at port ``9000``:
``shell zaku --port 9000 --verbose``
Now you can run the tests by running
.. code-block:: shell
pytest
In pycharm, you should see the following:
.. raw:: html
<p align="center">
.. raw:: html
</p>