Skip to contents

Node kinds have a structural component (stored in the graph) and a runtime component (the executor, stored in the handle).

Usage

bg_register_node_kind(
  project,
  kind,
  input_contract = NULL,
  output_type = NULL,
  param_schema = NULL,
  executor = NULL,
  pad = NULL
)

Arguments

project

A bg_handle.

kind

The name of the node kind.

input_contract

Optional input contract for the structural graph.

output_type

Optional output type string.

param_schema

Optional parameter schema.

executor

Optional R function to execute nodes of this kind. It is called as executor(node, inputs), where inputs is a list of upstream artifacts named by node id. It may return the artifact itself, or an envelope list(result = , summaries = , metadata = ). Without summaries, a list is treated as an envelope only when it has exactly one of result or artifact, has metadata, and has no other entries; any other list is stored as the artifact. A metadata$provenance = list(consumed = , effective = ) entry reports what the execution consumed (consumed$D, the data input ids it used; consumed$subject, the input id of the fit a check evaluated; consumed$data_files, list(node_id, path) entries naming file-path inputs it read) and the settings it actually used (effective$P, effective$A). Without a report, every input counts as consumed data. For kinds that declare pad, file-backed data is supported only as a non-empty regular file hashed before the run at the identical path, resolved in the executing process: every consumed D input whose value is a character string must be such a file (empty files, devices, FIFOs, and other special files are unsupported and never opened), every data_files entry must name a consumed D input at that path, the stan_file source and its includes must exist, and none of these may change during execution. Otherwise the provenance records a capture_error and no P/A/D snapshot; inputs that were not consumed are never checked.

pad

Optional P/A/D classification of the kind's parameters: a named list with character vectors P (model), A (algorithm), D (data), locator (parameters that select inputs, such as data_input), and other (parameters that don't change the result's meaning, such as diagnostic thresholds). Each parameter may appear in one category only. When a node's parameters are all classified, each execution records a P/A/D snapshot with SHA-256 digests in its provenance (see bg_node_pad()); an unclassified parameter means no snapshot is recorded. The declaration is stored in the runtime manifest and restored by bg_open(). If provenance cannot be captured at all, the succeeded job records capture_error instead of provenance.

Value

Invisible TRUE, after the kind is recorded in the graph registry and the on-disk registration manifest. The executor is bound into the handle's in-memory runtime registry (and its serialized source stored in the manifest entry) only when executor is supplied.