Skip to main content

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

Metadata

Release files for kubicle 0.1.29

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kubicle 0.1.29
File Size Uploaded
kubicle-0.1.29.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kubicle 0.1.29
File Interpreter ABI Platform
kubicle-0.1.29-py3-none-any.whl Python 3 none any Details

Total release size: 26.8 kB

Release files / kubicle-0.1.29.tar.gz

Download URL kubicle-0.1.29.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f6bbaa5ee4f451b94ba5e58fd060b596f08699c37cb3699c40d9e4e115357cf5
BLAKE2b-256 checksum
How to use checksums
71ef6745a50d9cdba457e2027aef777808d9826fc4786d29495ccf92d8bdf153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.1 Darwin/23.3.0

Release files / kubicle-0.1.29-py3-none-any.whl

Download URL kubicle-0.1.29-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3135b385bde791ef5c3fee4d39cee667358c37adfa2a66bbeb8ed5ef1ba7049
BLAKE2b-256 checksum
How to use checksums
4e5090450a68698387f74346c352328ad7215df995a1bab2a89241b3957a3e5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.1 Darwin/23.3.0

Release history Release notifications | RSS feed

This release

0.1.29 This release

2 release files

0.1.28

2 release files

0.1.26

2 release files

0.1.25

2 release files

0.1.24

2 release files

0.1.23

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page