Python serverless framework for Datastone Sprite GPU.
Project description
Sprite-GPU
Install
pip install sprite-gpu
Usage example
from sprite_gpu import start
def handler(request: Dict[str, Any]):
"""
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]):
"""
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]):
"""
returned object to be serialized into JSON and sent to the client.
"""
return {"output": "hello"}
async def async_gen_handler(request: Dict[str, Any]):
"""
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.2.tar.gz
(16.2 kB
view hashes)
Built Distribution
sprite_gpu-0.0.2-py3-none-any.whl
(12.9 kB
view hashes)
Close
Hashes for sprite_gpu-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8025c6eac52a4e0a25fe464c26f7346f85c4e3fbf5617212b3890ad341dc82a2 |
|
MD5 | 7fb3fe96a60c65f5a3cbd836cf022a78 |
|
BLAKE2b-256 | 14595cae93fe6cda10f713a8feda75e68c9b87c811352878bacbaa2f35244c0c |