Kernels#
moruna.kernel#
moruna.kernel(
fn=None, *, stateful=False, instances=1, device_memory=False,
accepts="table", tier="host", releases_gil=None,
expected_amplification=None, preferred_rows=None, resume="reinit",
state_bytes=None, input_schema=None, output_schema=None,
lockfile=None, memory_guard=True,
) -> moruna.KernelSpec | decorator
Use @moruna.kernel, @moruna.kernel(...), or moruna.kernel(obj, ...). When fn is omitted, the call returns a decorator; otherwise it returns a KernelSpec. A stateless function receives and returns a pyarrow.RecordBatch. An annotated Polars DataFrame or LazyFrame function is converted through Polars.
Parameter |
Type and default |
Meaning |
|---|---|---|
|
callable or object, optional |
Function to wrap, or stateful object when |
|
|
Call |
|
|
Independent copies of state; at least 1. |
|
|
Declare device memory use. |
|
|
|
|
|
|
|
|
Whether the callable releases Python’s GIL; |
|
|
Expected working memory divided by input size. |
|
|
Preferred batch row count. |
|
|
|
|
|
Estimated bytes per state instance. |
|
schema or mapping, optional |
|
|
schema or mapping, optional |
Exact schema, required-column mapping, or relative |
|
path or bytes, optional |
Contents are included in the fingerprint; paths are read at decoration time. |
|
|
Refuse an allocation that crosses the process memory ceiling. |
Schema mappings accept Arrow types, their string spellings, Python int, float, str, bool, and supported Polars types. A stateful object supplies setup(self, ctx) -> state and __call__(self, state, batch) -> batch; ctx has instance and device. It may supply footprint(self, state). With resume="checkpoint", it must also implement checkpoint(self, state) -> bytes and restore(self, ctx, data) -> state. Invalid declarations or options raise TypeError or ValueError at decoration time.
moruna.KernelSpec#
The frozen object returned by moruna.kernel has no public constructor.
Member |
Type |
Meaning |
|---|---|---|
|
delegated call |
Calls the wrapped Python object and returns its result. |
|
object |
Original callable. |
|
|
Whether this kernel keeps state. |
|
|
Whether allocation refusal is on. |
|
|
64-character lowercase hexadecimal fingerprint. |
moruna.polars#
moruna.polars(fn, *, accepts="table", **declarations) -> moruna.KernelSpec
Wraps an unannotated Polars function taking and returning a DataFrame or LazyFrame. accepts has the same choices as moruna.kernel. Supported declaration names are input_schema, output_schema, and lockfile, with the same meanings above. Returns a stateless KernelSpec.