https://github.com/astariul/gibbs
Scale your ML workers asynchronously across processes and machines
https://github.com/astariul/gibbs
asyncio deep-learning machine-learning ml mlops multiprocessing python zmq
Last synced: over 1 year ago
JSON representation
Scale your ML workers asynchronously across processes and machines
- Host: GitHub
- URL: https://github.com/astariul/gibbs
- Owner: astariul
- License: mit
- Created: 2022-03-09T05:13:15.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-02-14T13:31:35.000Z (over 2 years ago)
- Last Synced: 2024-03-14T15:51:16.977Z (over 2 years ago)
- Topics: asyncio, deep-learning, machine-learning, ml, mlops, multiprocessing, python, zmq
- Language: Python
- Homepage: https://astariul.github.io/gibbs
- Size: 3.16 MB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
gibbs
Scale your ML workers asynchronously across processes and machines
Description •
Install •
Usage •
FAQ •
Contribute
Documentation
Description
**`gibbs`** is a python package that helps you scale your ML workers (or any python code) across processes and machines, asynchronously.
`gibbs` is :
* ⚡️ Highly performant
* 🔀 Asynchronous
* 🐥 Easy-to-use
Install
Install `gibbs` by running :
```
pip install gibbs
```
Usage
After defining your awesome model :
```python
import time
class MyAwesomeModel:
def __init__(self, wait_time=0.25):
super().__init__()
self.w = wait_time
def __call__(self, x):
time.sleep(self.w)
return x**2
```
You can simply start a few workers serving the model :
```python
from gibbs import Worker
for _ in range(4):
Worker(MyAwesomeModel).start()
```
And send requests through the Hub :
```python
from gibbs import Hub
hub = Hub()
# In an async function
await hub.request(34)
```
And that's it !
---
Make sure to check the [documentation](https://astariul.github.io/gibbs/usage/) for a more detailed explanation.
Or you can run some examples from the `examples/` folder.
FAQ
#### ❓ **How `gibbs` works ?**
`gibbs` simply run your model code in separate processes, and send requests to the right process to ensure requests are treated in parallel.
`gibbs` uses a modified form of [the Paranoid Pirate Pattern from the zmq guide](https://zguide.zeromq.org/docs/chapter4/#Robust-Reliable-Queuing-Paranoid-Pirate-Pattern).
#### ❓ **Why the name "gibbs" ?**
Joshamee Gibbs is the devoted first mate of Captain Jack Sparrow.
Since we are using the Paranoid Pirate Pattern, we needed a pirate name !
Contribute
To contribute, install the package locally, create your own branch, add your code (and tests, and documentation), and open a PR !
### Pre-commit hooks
Pre-commit hooks are set to check the code added whenever you commit something.
If you never ran the hooks before, install it with :
```bash
pre-commit install
```
---
Then you can just try to commit your code. If you code does not meet the quality required by linters, it will not be committed. You can just fix your code and try to commit again !
---
You can manually run the pre-commit hooks with :
```bash
pre-commit run --all-files
```
### Tests
When you contribute, you need to make sure all the unit-tests pass. You should also add tests if necessary !
You can run the tests with :
```bash
pytest
```
---
Pre-commit hooks will not run the tests, but it will automatically update the coverage badge !
### Documentation
The documentation should be kept up-to-date. You can visualize the documentation locally by running :
```bash
mkdocs serve
```