Python serverless framework for Datastone Sprite GPU.
Project description
Sprite-GPU
Install
pip install sprite-gpu
Usage example
from sprite_gpu import start
from sprite_gpu.env import Env
def handler(request: Dict[str, Any], env: Env):
"""
request: Dict[str, Any], from client http request body.
request["input"]: Required.
request["webhook"]: Optional string for asynchronous requests.
returned object to be serialized into JSON and sent to the client.
in this case: '{"output": "hello"}'
"""
return {"output": "hello"}
def gen_handler(request: Dict[str, Any], env: Env):
"""
append yield output to array, serialize into JSON and send to client.
in this case: [0, 1, 2, 3, 4]
"""
for i in range(5):
yield i
async def async_handler(request: Dict[str, Any], env: Env):
"""
returned object to be serialized into JSON and sent to the client.
"""
return {"output": "hello"}
async def async_gen_handler(request: Dict[str, Any], env: Env):
"""
append yield output to array, serialize into JSON and send to client.
"""
for i in range(10):
yield i
def concurrency_modifier(current_allowed_concurrency: int) -> int:
"""
Adjusts the allowed concurrency level based on the current state.
For example, if the current allowed concurrency is 3 and resources are sufficient,
it can be increased to 5, allowing 5 tasks to run concurrently.
"""
allowed_concurrency = ...
return allowed_concurrency
"""
Register the handler with serverless.start().
Handlers can be synchronous, asynchronous, generators, or asynchronous generators.
"""
start({
"handler": async_handler, "concurrency_modifier": concurrency_modifier
})
API
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
sprite_gpu-0.0.6.tar.gz
(16.4 kB
view details)
Built Distribution
File details
Details for the file sprite_gpu-0.0.6.tar.gz
.
File metadata
- Download URL: sprite_gpu-0.0.6.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f40a0fff6b64544a2859c6bc61140f701f5783e0ab2c9549ac6663caca3c26c6 |
|
MD5 | 342c91963859c136fa0a21aedd960fa5 |
|
BLAKE2b-256 | 387e17c67821b34e8519e7101e37c1da7641b16c164aeded571a5878765814e5 |
File details
Details for the file sprite_gpu-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: sprite_gpu-0.0.6-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0509abc6a9c551bcaeee3b27ed62a1525ac42a08b600c78e90c8c11d5aef7eee |
|
MD5 | 80a0ed848429395a9922922b57ba6929 |
|
BLAKE2b-256 | 64f1a53e34fb22ac651e493ae80cd69e10cbfa946ff8e5eebad10cfb783356a2 |