table_operation
Register a function as the implementation of a named table operation.
from plexora.api import table_operationtable_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
namestrrequiredThe operation's name, namespaced by plugin (e.g.
"roi.write_cell_columns") so two plugins cannot claim the same
name.
Returns
CallableA decorator that registers the function it is applied to, and returns that function unchanged.
Raises
ValueErrorIf 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", []))}Related
table_stream
Register a function as the implementation of a streamed table operation.
TableHandle
The feature table, whatever format it was imported from.