Metadata-Version: 2.1
Name: gibbs
Version: 0.2.0
Summary: Scale your ML workers asynchronously across processes and machines
Home-page: https://github.com/astariul/gibbs
Author: Nicolas REMOND
Author-email: remondnicola@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3.7
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: pyzmq (<24.0,>=22.3)
Requires-Dist: msgpack (~=1.0)
Requires-Dist: loguru (~=0.6)
Provides-Extra: all
Requires-Dist: pytest (~=7.0) ; extra == 'all'
Requires-Dist: pytest-asyncio (~=0.18) ; extra == 'all'
Requires-Dist: pytest-cov (~=3.0) ; extra == 'all'
Requires-Dist: coverage-badge (~=1.0) ; extra == 'all'
Requires-Dist: pre-commit (~=2.15) ; extra == 'all'
Requires-Dist: isort (~=5.9) ; extra == 'all'
Requires-Dist: black (~=22.1) ; extra == 'all'
Requires-Dist: flake518 (~=1.2) ; extra == 'all'
Requires-Dist: darglint (~=1.8) ; extra == 'all'
Requires-Dist: mkdocs-material (~=8.1) ; extra == 'all'
Requires-Dist: mkdocstrings[python] (~=0.18) ; extra == 'all'
Requires-Dist: mike (~=1.1) ; extra == 'all'
Requires-Dist: fastapi (~=0.75) ; extra == 'all'
Requires-Dist: uvicorn (~=0.17) ; extra == 'all'
Requires-Dist: requests (~=2.27) ; extra == 'all'
Requires-Dist: transformers (~=4.17) ; extra == 'all'
Provides-Extra: dev
Requires-Dist: pytest (~=7.0) ; extra == 'dev'
Requires-Dist: pytest-asyncio (~=0.18) ; extra == 'dev'
Requires-Dist: pytest-cov (~=3.0) ; extra == 'dev'
Requires-Dist: coverage-badge (~=1.0) ; extra == 'dev'
Requires-Dist: pre-commit (~=2.15) ; extra == 'dev'
Requires-Dist: isort (~=5.9) ; extra == 'dev'
Requires-Dist: black (~=22.1) ; extra == 'dev'
Requires-Dist: flake518 (~=1.2) ; extra == 'dev'
Requires-Dist: darglint (~=1.8) ; extra == 'dev'
Requires-Dist: mkdocs-material (~=8.1) ; extra == 'dev'
Requires-Dist: mkdocstrings[python] (~=0.18) ; extra == 'dev'
Requires-Dist: mike (~=1.1) ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material (~=8.1) ; extra == 'docs'
Requires-Dist: mkdocstrings[python] (~=0.18) ; extra == 'docs'
Requires-Dist: mike (~=1.1) ; extra == 'docs'
Provides-Extra: ex
Requires-Dist: fastapi (~=0.75) ; extra == 'ex'
Requires-Dist: uvicorn (~=0.17) ; extra == 'ex'
Requires-Dist: requests (~=2.27) ; extra == 'ex'
Requires-Dist: transformers (~=4.17) ; extra == 'ex'
Provides-Extra: hook
Requires-Dist: pre-commit (~=2.15) ; extra == 'hook'
Provides-Extra: lint
Requires-Dist: isort (~=5.9) ; extra == 'lint'
Requires-Dist: black (~=22.1) ; extra == 'lint'
Requires-Dist: flake518 (~=1.2) ; extra == 'lint'
Requires-Dist: darglint (~=1.8) ; extra == 'lint'
Provides-Extra: test
Requires-Dist: pytest (~=7.0) ; extra == 'test'
Requires-Dist: pytest-asyncio (~=0.18) ; extra == 'test'
Requires-Dist: pytest-cov (~=3.0) ; extra == 'test'
Requires-Dist: coverage-badge (~=1.0) ; extra == 'test'

<h1 align="center">gibbs</h1>
<p align="center">
Scale your ML workers asynchronously across processes and machines
</p>

<p align="center">
    <a href="https://github.com/astariul/gibbs/releases"><img src="https://img.shields.io/github/release/astariul/gibbs.svg" alt="GitHub release" /></a>
    <a href="https://github.com/astariul/gibbs/actions/workflows/pytest.yaml"><img src="https://github.com/astariul/gibbs/actions/workflows/pytest.yaml/badge.svg" alt="Test status" /></a>
    <a href="https://github.com/astariul/gibbs/actions/workflows/lint.yaml"><img src="https://github.com/astariul/gibbs/actions/workflows/lint.yaml/badge.svg" alt="Lint status" /></a>
    <img src=".github/badges/coverage.svg" alt="Coverage status" />
    <a href="https://astariul.github.io/gibbs"><img src="https://img.shields.io/website?down_message=failing&label=docs&up_color=green&up_message=passing&url=https%3A%2F%2Fastariul.github.io%2Fgibbs" alt="Docs" /></a>
    <a href="https://github.com/astariul/gibbs/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="licence" /></a>
</p>

<p align="center">
  <a href="#description">Description</a> •
  <a href="#install">Install</a> •
  <a href="#usage">Usage</a> •
  <a href="#faq">FAQ</a> •
  <a href="#contribute">Contribute</a>
  <br>
  <a href="https://astariul.github.io/gibbs/" target="_blank">Documentation</a>
</p>


<h2 align="center">Description</h2>

**`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


<h2 align="center">Install</h2>

Install `gibbs` by running :


```
pip install gibbs
```


<h2 align="center">Usage</h2>

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.


<h2 align="center">FAQ</h2>

#### ❓ **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 !

<h2 align="center">Contribute</h2>

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
```


