Background jobs on Kubernetes
Project description
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 BaseModel
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
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
from kubicle import JobStatus
while True:
job.refresh()
if job.status == JobStatus.FINISHED:
break
Get the result
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:
DB_TYPE=postgres
DB_NAME=jobs
DB_HOST=localhost
DB_USER=postgres
DB_PASS=abc123
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kubicle-0.1.16.tar.gz
.
File metadata
- Download URL: kubicle-0.1.16.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f3d7593941747036006e1e0765934750a24b48b85dd15c0333ee0f5d6c25a8b |
|
MD5 | 06a168f63ef72d489e6da29570f36a6a |
|
BLAKE2b-256 | 6c3a822487c75b15bcb99f3f1cc9e85760cd636b553b99d4b16df6a0e1aeb456 |
File details
Details for the file kubicle-0.1.16-py3-none-any.whl
.
File metadata
- Download URL: kubicle-0.1.16-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ea43a59f17fa0b37d57bf4665fe11d03d8f293568bc4c3db4a54cc55636252d |
|
MD5 | 9f99dc3cbb320a6e915d1971cb2261b3 |
|
BLAKE2b-256 | 47f06dfd7f3323bb83cd29720476fe366e917598732b70f86c910d16df760488 |