sprite-gpu


Namesprite-gpu JSON
Version 0.0.6 PyPI version JSON
download
home_pagehttps://github.com/datastone-sprite
SummaryPython serverless framework for Datastone Sprite GPU.
upload_time2024-08-19 11:20:53
maintainerNone
docs_urlNone
authorSprite
requires_python>=3.9
licenseMIT License
keywords serverless ai gpu machine learning sdk library python api
VCS
bugtrack_url
requirements requests PyYAML backoff aiohttp pydantic
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Sprite-GPU

- [Sprite-GPU](#sprite-gpu)
  - [Install](#install)
  - [Usage example](#usage-example)
  - [API](#api)

## Install
```
pip install sprite-gpu
```

## Usage example

```python
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
See [API](https://github.com/datastone-sprite/sprite-gpu/blob/main/API.md) or [中文 API](https://github.com/datastone-sprite/sprite-gpu/blob/main/API.zh.md) for more details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/datastone-sprite",
    "name": "sprite-gpu",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "serverless, ai, gpu, machine learning, SDK, library, python, API",
    "author": "Sprite",
    "author_email": "Sprite <pypi@datastone.cn>",
    "download_url": "https://files.pythonhosted.org/packages/38/7e/17c67821b34e8519e7101e37c1da7641b16c164aeded571a5878765814e5/sprite_gpu-0.0.6.tar.gz",
    "platform": null,
    "description": "# Sprite-GPU\n\n- [Sprite-GPU](#sprite-gpu)\n  - [Install](#install)\n  - [Usage example](#usage-example)\n  - [API](#api)\n\n## Install\n```\npip install sprite-gpu\n```\n\n## Usage example\n\n```python\nfrom sprite_gpu import start\nfrom sprite_gpu.env import Env\n\n\ndef handler(request: Dict[str, Any], env: Env):\n    \"\"\"\n    request: Dict[str, Any], from client http request body.\n    request[\"input\"]: Required.\n    request[\"webhook\"]: Optional string for asynchronous requests.\n\n    returned object to be serialized into JSON and sent to the client.\n    in this case: '{\"output\": \"hello\"}'\n    \"\"\"\n    return {\"output\": \"hello\"}\n\n\ndef gen_handler(request: Dict[str, Any], env: Env):\n    \"\"\"\n    append yield output to array, serialize into JSON and send to client.\n    in this case: [0, 1, 2, 3, 4]\n    \"\"\"\n    for i in range(5):\n        yield i\n\n\nasync def async_handler(request: Dict[str, Any], env: Env):\n    \"\"\"\n    returned object to be serialized into JSON and sent to the client.\n    \"\"\"\n    return {\"output\": \"hello\"}\n\n\nasync def async_gen_handler(request: Dict[str, Any], env: Env):\n    \"\"\"\n    append yield output to array, serialize into JSON and send to client.\n    \"\"\"\n    for i in range(10):\n        yield i\n\n\ndef concurrency_modifier(current_allowed_concurrency: int) -> int:\n    \"\"\"\n    Adjusts the allowed concurrency level based on the current state.\n    For example, if the current allowed concurrency is 3 and resources are sufficient,\n    it can be increased to 5, allowing 5 tasks to run concurrently.\n    \"\"\"\n    allowed_concurrency = ...\n    return allowed_concurrency\n\n\n\"\"\"\nRegister the handler with serverless.start().\nHandlers can be synchronous, asynchronous, generators, or asynchronous generators.\n\"\"\"\nstart({\n    \"handler\": async_handler, \"concurrency_modifier\": concurrency_modifier\n})\n```\n\n## API\nSee [API](https://github.com/datastone-sprite/sprite-gpu/blob/main/API.md) or [\u4e2d\u6587 API](https://github.com/datastone-sprite/sprite-gpu/blob/main/API.zh.md) for more details.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Python serverless framework for Datastone Sprite GPU.",
    "version": "0.0.6",
    "project_urls": {
        "BugTracker": "https://github.com/datastone-sprite/sprite-gpu/issues",
        "Documentation": "https://github.com/datastone-sprite/sprite-gpu/blob/main/README.md",
        "Homepage": "https://github.com/datastone-sprite",
        "Repository": "https://github.com/datastone-sprite/sprite-gpu"
    },
    "split_keywords": [
        "serverless",
        " ai",
        " gpu",
        " machine learning",
        " sdk",
        " library",
        " python",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "64f1a53e34fb22ac651e493ae80cd69e10cbfa946ff8e5eebad10cfb783356a2",
                "md5": "80a0ed848429395a9922922b57ba6929",
                "sha256": "0509abc6a9c551bcaeee3b27ed62a1525ac42a08b600c78e90c8c11d5aef7eee"
            },
            "downloads": -1,
            "filename": "sprite_gpu-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "80a0ed848429395a9922922b57ba6929",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 12996,
            "upload_time": "2024-08-19T11:20:52",
            "upload_time_iso_8601": "2024-08-19T11:20:52.314141Z",
            "url": "https://files.pythonhosted.org/packages/64/f1/a53e34fb22ac651e493ae80cd69e10cbfa946ff8e5eebad10cfb783356a2/sprite_gpu-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "387e17c67821b34e8519e7101e37c1da7641b16c164aeded571a5878765814e5",
                "md5": "342c91963859c136fa0a21aedd960fa5",
                "sha256": "f40a0fff6b64544a2859c6bc61140f701f5783e0ab2c9549ac6663caca3c26c6"
            },
            "downloads": -1,
            "filename": "sprite_gpu-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "342c91963859c136fa0a21aedd960fa5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 16382,
            "upload_time": "2024-08-19T11:20:53",
            "upload_time_iso_8601": "2024-08-19T11:20:53.671358Z",
            "url": "https://files.pythonhosted.org/packages/38/7e/17c67821b34e8519e7101e37c1da7641b16c164aeded571a5878765814e5/sprite_gpu-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-19 11:20:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "datastone-sprite",
    "github_project": "sprite-gpu",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.31.0"
                ]
            ]
        },
        {
            "name": "PyYAML",
            "specs": [
                [
                    ">=",
                    "6.0.1"
                ]
            ]
        },
        {
            "name": "backoff",
            "specs": [
                [
                    ">=",
                    "2.2.1"
                ]
            ]
        },
        {
            "name": "aiohttp",
            "specs": [
                [
                    ">=",
                    "3.9.1"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    ">=",
                    "2.5.2"
                ]
            ]
        }
    ],
    "lcname": "sprite-gpu"
}
        
Elapsed time: 0.42791s