kubicle


Namekubicle JSON
Version 0.1.29 PyPI version JSON
download
home_pageNone
SummaryBackground jobs on Kubernetes
upload_time2024-10-25 21:00:48
maintainerNone
docs_urlNone
authorPatrick Barker
requires_python<4.0,>=3.10
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Kubicle

Python background jobs on Kubernetes

-> No runtime dependencies, simply run Python functions on Kubernetes and get the results back.

## Installation

```
pip install kubicle
```

## Usage

Define a python function with inputs and an output that use [pydantic](https://docs.pydantic.dev/latest/) `BaseModel`

```py
from pydantic import BaseModel

class Foo(BaseModel):
    a: int
    b: str

class Bar(BaseModel):
    c: float
    d: bool


def call_me_remote(foo: Foo) -> Bar:
    ...

```

Run as a Kubernetes job

```py
from kubicle import Runner

os.environ["JOB_IMG"] = "foo/bar:latest"

runner = Runner()

job = runner.run(call_me_remote, Foo(a=1, b="hello"))

```

Wait for the job to finish

```py
from kubicle import JobStatus

while True:
    job.refresh()
    if job.status == JobStatus.FINISHED:
        break
```

Get the result

```py
bar = Bar.model_validate_json(job.result)
```

### Local

When in development it can be handy to run the job locally.

Do this by setting env var `JOB_LOCAL=true` or passing the parameter on object creation `Runner(local=true)` and the job will execute using multiprocessing.

## Backends

Job storage can be backed by:

- Sqlite
- Postgresql

Sqlite will be used by default. To use postgres simply configure the env vars:

```sh
DB_TYPE=postgres
DB_NAME=jobs
DB_HOST=localhost
DB_USER=postgres
DB_PASS=abc123
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "kubicle",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Patrick Barker",
    "author_email": "patrickbarkerco@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/71/ef/6745a50d9cdba457e2027aef777808d9826fc4786d29495ccf92d8bdf153/kubicle-0.1.29.tar.gz",
    "platform": null,
    "description": "# Kubicle\n\nPython background jobs on Kubernetes\n\n-> No runtime dependencies, simply run Python functions on Kubernetes and get the results back.\n\n## Installation\n\n```\npip install kubicle\n```\n\n## Usage\n\nDefine a python function with inputs and an output that use [pydantic](https://docs.pydantic.dev/latest/) `BaseModel`\n\n```py\nfrom pydantic import BaseModel\n\nclass Foo(BaseModel):\n    a: int\n    b: str\n\nclass Bar(BaseModel):\n    c: float\n    d: bool\n\n\ndef call_me_remote(foo: Foo) -> Bar:\n    ...\n\n```\n\nRun as a Kubernetes job\n\n```py\nfrom kubicle import Runner\n\nos.environ[\"JOB_IMG\"] = \"foo/bar:latest\"\n\nrunner = Runner()\n\njob = runner.run(call_me_remote, Foo(a=1, b=\"hello\"))\n\n```\n\nWait for the job to finish\n\n```py\nfrom kubicle import JobStatus\n\nwhile True:\n    job.refresh()\n    if job.status == JobStatus.FINISHED:\n        break\n```\n\nGet the result\n\n```py\nbar = Bar.model_validate_json(job.result)\n```\n\n### Local\n\nWhen in development it can be handy to run the job locally.\n\nDo this by setting env var `JOB_LOCAL=true` or passing the parameter on object creation `Runner(local=true)` and the job will execute using multiprocessing.\n\n## Backends\n\nJob storage can be backed by:\n\n- Sqlite\n- Postgresql\n\nSqlite will be used by default. To use postgres simply configure the env vars:\n\n```sh\nDB_TYPE=postgres\nDB_NAME=jobs\nDB_HOST=localhost\nDB_USER=postgres\nDB_PASS=abc123\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Background jobs on Kubernetes",
    "version": "0.1.29",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4e5090450a68698387f74346c352328ad7215df995a1bab2a89241b3957a3e5e",
                "md5": "52884298255ce12dd14dc4e089e81360",
                "sha256": "e3135b385bde791ef5c3fee4d39cee667358c37adfa2a66bbeb8ed5ef1ba7049"
            },
            "downloads": -1,
            "filename": "kubicle-0.1.29-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "52884298255ce12dd14dc4e089e81360",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 15128,
            "upload_time": "2024-10-25T21:00:47",
            "upload_time_iso_8601": "2024-10-25T21:00:47.048570Z",
            "url": "https://files.pythonhosted.org/packages/4e/50/90450a68698387f74346c352328ad7215df995a1bab2a89241b3957a3e5e/kubicle-0.1.29-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "71ef6745a50d9cdba457e2027aef777808d9826fc4786d29495ccf92d8bdf153",
                "md5": "3a7d6da25804ce9eae83ab4519601f9a",
                "sha256": "f6bbaa5ee4f451b94ba5e58fd060b596f08699c37cb3699c40d9e4e115357cf5"
            },
            "downloads": -1,
            "filename": "kubicle-0.1.29.tar.gz",
            "has_sig": false,
            "md5_digest": "3a7d6da25804ce9eae83ab4519601f9a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 11720,
            "upload_time": "2024-10-25T21:00:48",
            "upload_time_iso_8601": "2024-10-25T21:00:48.332999Z",
            "url": "https://files.pythonhosted.org/packages/71/ef/6745a50d9cdba457e2027aef777808d9826fc4786d29495ccf92d8bdf153/kubicle-0.1.29.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-25 21:00:48",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "kubicle"
}
        
Elapsed time: 0.41624s