Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kubicle-0.1.9.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

kubicle-0.1.9-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file kubicle-0.1.9.tar.gz.

File metadata

  • Download URL: kubicle-0.1.9.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.4.0

File hashes

Hashes for kubicle-0.1.9.tar.gz
Algorithm Hash digest
SHA256 cf93f4c38caa685c41616ca20555d9684b4a0c27aa0d218a224b3830b5f6e9d5
MD5 44f79dc6e4e4f4b883eb48dc8dc01d4e
BLAKE2b-256 817466d7cae395ff963a42510256dfe140cf3af19afadc3ddb81dad6ea452770

See more details on using hashes here.

File details

Details for the file kubicle-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: kubicle-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 13.1 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

Hashes for kubicle-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 6652d8e4c1abfbfae8d3afee02ab917f0bb3a80aaf5a2e797233f00c019b8997
MD5 4a66e840a8120b3bf0e975a6f64090b9
BLAKE2b-256 f33f1b3976aa8ee22bda38497025d773c9d07944efd90e5a3d3286688ef0735d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page