Compute Service
This is a Python library to create Compute Service with REST API and task queue.
Usage
To create new compute service one need to:
- Import packages
from pydantic import BaseModel
from compute_service import ComputeService
- Create service object with selected queue type:
service = ComputeService(queue='kafka')
kafka and local queue types are supported.
- Define model for input parameters and app factory:
class UserBase(BaseModel):
title: str
value: int
def create_app():
return service.create_app(UserBase)
- Define task processing callback and task handler:
def process(data):
print(f'Got data: {data}')
return {'ok': 'success'}
if __name__ == '__main__':
handler = service.create_handler(process)
handler.start()
- Start REST API:
uvicorn 'my_service:create_app'
- Start task handler:
python my_service.py
Release files for compute-service 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| compute_service-0.0.1.tar.gz | 9.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| compute_service-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:24.1 kB
Release files / compute_service-0.0.1.tar.gz
| Download URL | compute_service-0.0.1.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f22d95ee22a28280664b90d0a5c05e0ca23cf794338d13e3328b34d2e7e4653
|
|
BLAKE2b-256 checksum How to use checksums |
a070697690867f45299a7415cac164499961fbac55a1f9e3f1fce361ac06baa2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / compute_service-0.0.1-py3-none-any.whl
| Download URL | compute_service-0.0.1-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
52e92940456f0a1688374d0eeacb37d0ee56587f188fd5cee0d0f38cff7f3a01
|
|
BLAKE2b-256 checksum How to use checksums |
53e21bc2c3c87b1e9c6c66b7cb2159585467668ccffdb6d3c759223f659b8690
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|