Skip to main content
BlockX combines compute functions with triggers, inputs, and result writes. Use these driver interfaces in Notebooks by default; function.call() also supports reuse inside a Function. See the source for full implementations and low-level interfaces.

Synchronous Function calls

function.call(function_id, *args, timeout=5)

function_id is a saved Function ID, and *args are positional arguments passed as given, not converted to the Function’s declared parameter types. This example returns 1.5 after you create the example function in Create a Function. timeout is in seconds and defaults to 5, which is also the maximum; larger values are rejected. In a Notebook, you can set a shorter deadline. Inside a Function, nested calls are bounded by the parent’s remaining deadline; increasing a child timeout cannot extend the whole execution. Failures raise FunctionInvokeError, with commonly used attributes code, message, retryable, call_id, and origin. origin says where the failure belongs: FAILURE_ORIGIN_USER for an error in the function’s own code, FAILURE_ORIGIN_CAPACITY when no compute capacity is available, and FAILURE_ORIGIN_SYSTEM for a platform-side failure.

Function descriptor

Function(source_code=None, function_id='', name='', mode='inline')

Provide source code or a Function ID. This object describes a function for task configuration; constructing it does not execute or save the function. Block and bundle tasks accept a saved Function ID only; DirectCallConfig is the one that also accepts inline source.

Pipelines and triggers

Pipeline(sources, target, requires=None, condition=None, readiness=None)

Keys of a trigger-source dictionary: If a new block table has no start height, update() fills block by block from height 0, which takes a long time. Set the start height first if you only need recent data, or run backfill() first for history. The same table may appear in both sources and requires: as a source it supplies candidate heights, and as a dependency it requires that height to be fully processed. Common BackfillResult attributes: Batch writes in a large backfill may run asynchronously, so confirm the target table’s write jobs and consensus progress separately. For a runnable configuration, see Build a Pipeline.

Custom tasks

DirectCallConfig(func_id=None, args_list=None)

func_id accepts a Function ID, a callable, or a Function object. args_list is a list of positional-argument lists, and each sublist triggers one call.
A successful run prints [1.5, 2.0]. Raw result order is not guaranteed to match input order; carry a business ID in the return value when you need to correlate them.

TaskBuilder.build(call_config, handler)

Returns an unsubmitted Task. task.submit(timeout=None) submits and waits, returning TaskResult; timeout is in seconds and defaults to the server’s own value. Asynchronous Python code can use await task.submit_async(timeout=...).

Block task inputs

sources uses the same keys as a Pipeline’s trigger sources, and ROW marks the argument position of the source record.

Result handlers

The block handler carries no block or bundle of its own: the write position comes from the same task’s input configuration, so the two cannot disagree. It therefore requires a BlockCallConfig or a BundleCallConfig. A standard Pipeline picks the handler from the target table’s kind. Per-block writes have the server fill in the three block fields. Bundle writes do not: a bundle whose records lack them fails to write, while the backfill result still reports success. The full bundles within backfill() and every backfill_block_bundles() run are written by bundle, so copy the three fields from the source record and return them.

Backfill helpers

backfill_block_bundles(start_bundle_id, end_bundle_id, config, handler, *, retry=2, timeout=None, progress=None, abort_if_first_fails=True) runs a custom bundle backfill: pass a BundleCallConfigTemplate as config and a write handler as handler. The range is inclusive on both ends, and it returns a BackfillSummary. retry is the number of on-the-spot retries per bundle. When the first bundle still fails after its retries, the whole run aborts by default, because that is usually a configuration problem. Omitting progress prints progress by completion percentage; pass a callable to handle it yourself. bundle_height_range(bundle_id) returns the height range a bundle covers. For low-level configuration and the LocalTestService testing interface, see GitHub.