Plexora

table_operation

Register a function as the implementation of a named table operation.

Generated from Plexora 0.0.55View source
from plexora.api import table_operation
table_operation(name: str)

A TableHandle runs the operation by this name, whether the table is on this machine or on a node -- the same registered function runs at whichever end holds the table, so plugin code never has to know which one it is on.

The registered function takes the dataset handle for the project the table belongs to and a JSON-serializable payload, and returns a JSON-serializable result. That signature is the wire format: anything that cannot survive json.dumps cannot be an argument or a result, which is deliberate -- an operation that wants to pass a whole DataFrame is an operation that has not decided where it runs.

Parameters

namestrrequired

The operation's name, namespaced by plugin (e.g. "roi.write_cell_columns") so two plugins cannot claim the same name.

Returns

Callable

A decorator that registers the function it is applied to, and returns that function unchanged.

Raises

ValueError

If a different function is already registered under name.

Examples

from plexora.api import table_operation

@table_operation("my_plugin.count_rows")
def _count_rows(dataset, payload):
    return {"rows": len(payload.get("ids", []))}

Guides

On this page